mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-27 12:50:51 +03:00
Merge pull request #266 from ajayyy/experimental
Options page improvements + Preview sponsors
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "__MSG_Name__",
|
||||
"version": "1.2.5",
|
||||
"version": "1.2.6",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"content_scripts": [
|
||||
|
||||
@@ -415,7 +415,7 @@
|
||||
"message": "Reset"
|
||||
},
|
||||
"customAddressError": {
|
||||
"message": "This address is not in the right form. Make sure you have http:// or https:// at the begining and no slashes or sub-folders at the end."
|
||||
"message": "This address is not in the right form. Make sure you have http:// or https:// at the begining and no trailing slashes."
|
||||
},
|
||||
"areYouSureReset": {
|
||||
"message": "Are you sure you would like to reset this?"
|
||||
|
||||
@@ -379,8 +379,20 @@ function sponsorsLookup(id: string, channelIDPromise?) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
sponsorDataFound = true;
|
||||
|
||||
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||
UUIDs = JSON.parse(xmlhttp.responseText).UUIDs;
|
||||
let recievedSponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||
let recievedUUIDs = JSON.parse(xmlhttp.responseText).UUIDs;
|
||||
|
||||
// Check if any old submissions should be kept
|
||||
for (let i = 0; i < UUIDs.length; i++) {
|
||||
if (UUIDs[i] === null) {
|
||||
// This is a user submission, keep it
|
||||
recievedSponsorTimes.push(sponsorTimes[i]);
|
||||
recievedUUIDs.push(UUIDs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
sponsorTimes = recievedSponsorTimes;
|
||||
UUIDs = recievedUUIDs;
|
||||
|
||||
// Remove all submissions smaller than the minimum duration
|
||||
if (Config.config.minDuration !== 0) {
|
||||
@@ -1091,10 +1103,12 @@ function sendSubmitMessage(){
|
||||
Config.config.sponsorTimes.delete(currentVideoID);
|
||||
|
||||
//add submissions to current sponsors list
|
||||
if (sponsorTimes === null) sponsorTimes = [];
|
||||
|
||||
sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
|
||||
for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
|
||||
// Add some random IDs
|
||||
UUIDs.push(utils.generateUserID());
|
||||
// Add placeholder IDs
|
||||
UUIDs.push(null);
|
||||
}
|
||||
|
||||
// Empty the submitting times
|
||||
|
||||
@@ -50,6 +50,16 @@ async function init() {
|
||||
switch (option) {
|
||||
case "supportInvidious":
|
||||
invidiousOnClick(checkbox, option);
|
||||
break;
|
||||
case "disableAutoSkip":
|
||||
if (!checkbox.checked) {
|
||||
// Enable the notice
|
||||
Config.config["dontShowNotice"] = false;
|
||||
|
||||
let showNoticeSwitch = <HTMLInputElement> document.querySelector("[sync-option='dontShowNotice'] > label > label > input");
|
||||
showNoticeSwitch.checked = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -357,14 +367,13 @@ function activatePrivateTextChange(element: HTMLElement) {
|
||||
* @param input Input server address
|
||||
*/
|
||||
function validateServerAddress(input: string): string {
|
||||
// Trim the last slash if needed
|
||||
if (input.endsWith("/")) {
|
||||
input = input.substring(0, input.length - 1);
|
||||
}
|
||||
input = input.trim();
|
||||
|
||||
// Isn't HTTP protocol or has extra slashes
|
||||
if ((!input.startsWith("https://") && !input.startsWith("http://"))
|
||||
|| input.replace("://", "").includes("/")) {
|
||||
// Trim the trailing slashes
|
||||
input = input.replace(/\/+$/, "");
|
||||
|
||||
// If it isn't HTTP protocol
|
||||
if ((!input.startsWith("https://") && !input.startsWith("http://"))) {
|
||||
|
||||
alert(chrome.i18n.getMessage("customAddressError"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user