mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-30 06:10:55 +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__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "__MSG_Name__",
|
"short_name": "__MSG_Name__",
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
|
|||||||
@@ -415,7 +415,7 @@
|
|||||||
"message": "Reset"
|
"message": "Reset"
|
||||||
},
|
},
|
||||||
"customAddressError": {
|
"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": {
|
"areYouSureReset": {
|
||||||
"message": "Are you sure you would like to reset this?"
|
"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) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
sponsorDataFound = true;
|
sponsorDataFound = true;
|
||||||
|
|
||||||
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
let recievedSponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||||
UUIDs = JSON.parse(xmlhttp.responseText).UUIDs;
|
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
|
// Remove all submissions smaller than the minimum duration
|
||||||
if (Config.config.minDuration !== 0) {
|
if (Config.config.minDuration !== 0) {
|
||||||
@@ -1091,10 +1103,12 @@ function sendSubmitMessage(){
|
|||||||
Config.config.sponsorTimes.delete(currentVideoID);
|
Config.config.sponsorTimes.delete(currentVideoID);
|
||||||
|
|
||||||
//add submissions to current sponsors list
|
//add submissions to current sponsors list
|
||||||
|
if (sponsorTimes === null) sponsorTimes = [];
|
||||||
|
|
||||||
sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
|
sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
|
||||||
for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
|
for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
|
||||||
// Add some random IDs
|
// Add placeholder IDs
|
||||||
UUIDs.push(utils.generateUserID());
|
UUIDs.push(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty the submitting times
|
// Empty the submitting times
|
||||||
|
|||||||
@@ -50,6 +50,16 @@ async function init() {
|
|||||||
switch (option) {
|
switch (option) {
|
||||||
case "supportInvidious":
|
case "supportInvidious":
|
||||||
invidiousOnClick(checkbox, option);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -357,14 +367,13 @@ function activatePrivateTextChange(element: HTMLElement) {
|
|||||||
* @param input Input server address
|
* @param input Input server address
|
||||||
*/
|
*/
|
||||||
function validateServerAddress(input: string): string {
|
function validateServerAddress(input: string): string {
|
||||||
// Trim the last slash if needed
|
input = input.trim();
|
||||||
if (input.endsWith("/")) {
|
|
||||||
input = input.substring(0, input.length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Isn't HTTP protocol or has extra slashes
|
// Trim the trailing slashes
|
||||||
if ((!input.startsWith("https://") && !input.startsWith("http://"))
|
input = input.replace(/\/+$/, "");
|
||||||
|| input.replace("://", "").includes("/")) {
|
|
||||||
|
// If it isn't HTTP protocol
|
||||||
|
if ((!input.startsWith("https://") && !input.startsWith("http://"))) {
|
||||||
|
|
||||||
alert(chrome.i18n.getMessage("customAddressError"));
|
alert(chrome.i18n.getMessage("customAddressError"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user