diff --git a/manifest/manifest.json b/manifest/manifest.json index 4f391a48..391b76af 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -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": [ diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index db260eb0..5e0d0407 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -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?" diff --git a/src/content.ts b/src/content.ts index dba13c35..05255f4b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -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 diff --git a/src/options.ts b/src/options.ts index 00a71bb9..1836c6c3 100644 --- a/src/options.ts +++ b/src/options.ts @@ -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 = 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"));