From 1d342b21fd2730ab801aba64f7f235f4e40adbba Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 8 Dec 2019 12:08:36 -0500 Subject: [PATCH 1/9] Added small guideline reminder to submission confirmation dialog. --- _locales/en/messages.json | 5 ++++- content.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f34542a7..6d2b40dc 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -76,7 +76,7 @@ "message": "Paused" }, "confirmMSG": { - "message": "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner." + "message": "To edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner." }, "clearThis": { "message": "Are you sure you want to clear this?\n\n" @@ -314,5 +314,8 @@ }, "youHaveSavedTimeEnd": { "message": " of their lives." + }, + "guildlinesSummary": { + "message": "- Make sure your segment only contains paid promotion segment, nothing else.\n- Make sure skipping this segment will not skip valuable content\n- If the whole video is a sponsor, please do not report it. A full video reporting system will come out soon.\n- Please do not report disclaimers that could show bias (if a review video is sponsored, don't skip when they mention that)." } } diff --git a/content.js b/content.js index 228172de..80ee0fea 100644 --- a/content.js +++ b/content.js @@ -1047,8 +1047,8 @@ function submitSponsorTimes() { //update sponsorTimes chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes}); - let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes); - confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG"); + let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes) + + "\n\n" + chrome.i18n.getMessage("confirmMSG") + "\n\n" + chrome.i18n.getMessage("guildlinesSummary"); if(!confirm(confirmMessage)) return; sendSubmitMessage(); From cc1a12e1a21c4455fa4368403c8f32d533fe6b3d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Dec 2019 17:06:30 -0500 Subject: [PATCH 2/9] Clarified that auto-upvote can be disabled. --- help/index_en.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help/index_en.html b/help/index_en.html index acf0c519..ac3a0987 100644 --- a/help/index_en.html +++ b/help/index_en.html @@ -39,7 +39,7 @@

- Whenever you skip a video, you will get a notice report that submission. If the timing seems wrong, report it! You can also vote in the popup. The extension auto upvotes it if you don't report it, so make sure to report when necessary. + Whenever you skip a video, you will get a notice report that submission. If the timing seems wrong, report it! You can also vote in the popup. The extension auto upvotes it if you don't report it, so make sure to report when necessary (this can be disabled in the options).

From 226c5d601c7ccc4e81ec8ecc2a30ea7e15367a0e Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Dec 2019 18:17:07 -0500 Subject: [PATCH 3/9] Added space to notification. --- background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background.js b/background.js index 7aaed64e..3961009b 100644 --- a/background.js +++ b/background.js @@ -33,7 +33,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { case "alertPrevious": chrome.notifications.create("stillThere" + Math.random(), { type: "basic", - title: chrome.i18n.getMessage("wantToSubmit") + request.previousVideoID + "?", + title: chrome.i18n.getMessage("wantToSubmit") + " " + request.previousVideoID + "?", message: chrome.i18n.getMessage("leftTimes"), iconUrl: "./icons/LogoSponsorBlocker256px.png" }); From b34e6076e40793fd56a847b551e4fb6d9c508f2e Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 13 Dec 2019 21:32:57 -0500 Subject: [PATCH 4/9] Moved error message handling to a util file and added a link to the status site. --- _locales/en/messages.json | 3 +++ content.js | 19 +++---------------- popup.js | 32 ++++---------------------------- utils.js | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 44 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 6d2b40dc..c0cb80bf 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -317,5 +317,8 @@ }, "guildlinesSummary": { "message": "- Make sure your segment only contains paid promotion segment, nothing else.\n- Make sure skipping this segment will not skip valuable content\n- If the whole video is a sponsor, please do not report it. A full video reporting system will come out soon.\n- Please do not report disclaimers that could show bias (if a review video is sponsored, don't skip when they mention that)." + }, + "statusReminder": { + "message": "Check status.sponsor.ajay.app for server status." } } diff --git a/content.js b/content.js index 80ee0fea..c509e6cc 100644 --- a/content.js +++ b/content.js @@ -980,14 +980,8 @@ function vote(type, UUID, skipNotice) { skipNotice.addNoticeInfoMessage.bind(skipNotice)(chrome.i18n.getMessage("voteFail")) skipNotice.resetVoteButtonInfo.bind(skipNotice)(); } else if (response.successType == -1) { - if (response.statusCode == 502) { - skipNotice.addNoticeInfoMessage.bind(skipNotice)(chrome.i18n.getMessage("serverDown")) - skipNotice.resetVoteButtonInfo.bind(skipNotice)(); - } else { - //failure: unknown error - skipNotice.addNoticeInfoMessage.bind(skipNotice)(chrome.i18n.getMessage("connectionError") + response.statusCode); - skipNotice.resetVoteButtonInfo.bind(skipNotice)(); - } + skipNotice.addNoticeInfoMessage.bind(skipNotice)(getErrorMessage(response.statusCode)) + skipNotice.resetVoteButtonInfo.bind(skipNotice)(); } } } @@ -1101,14 +1095,7 @@ function sendSubmitMessage(){ document.getElementById("submitButton").style.animation = "unset"; document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png"); - if([400, 429, 409, 502, 0].includes(response.statusCode)) { - //treat them the same - if (response.statusCode == 503) response.statusCode = 502; - - alert(chrome.i18n.getMessage(response.statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + response.statusCode); - } else { - alert(chrome.i18n.getMessage("connectionError") + response.statusCode); - } + alert(getErrorMessage(response.statusCode)); } } }); diff --git a/popup.js b/popup.js index d51fac4b..d5646e2c 100644 --- a/popup.js +++ b/popup.js @@ -895,18 +895,7 @@ function runThePopup() { clearTimes(); } else { - let errorMessage = ""; - - if([400, 429, 409, 502, 0].includes(response.statusCode)) { - //treat them the same - if (response.statusCode == 503) response.statusCode = 502; - - errorMessage = chrome.i18n.getMessage(response.statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + response.statusCode; - } else { - errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode; - } - - document.getElementById("submitTimesInfoMessage").innerText = errorMessage; + document.getElementById("submitTimesInfoMessage").innerText = getErrorMessage(response.statusCode); document.getElementById("submitTimesInfoMessageContainer").style.display = "unset"; SB.submitTimesInfoMessageContainer.style.display = "unset"; @@ -1138,7 +1127,7 @@ function runThePopup() { SB.usernameInput.style.display = "none"; SB.setUsernameStatusContainer.style.display = "unset"; - SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status; + SB.setUsernameStatus.innerText = getErrorMessage(xmlhttp.status); } }); }); @@ -1160,15 +1149,7 @@ function runThePopup() { SB.setUsernameStatus.innerText = chrome.i18n.getMessage("success"); } else if (xmlhttp.readyState == 4) { - let errorMessage = ""; - - if([400, 429, 409, 502].includes(xmlhttp.status)) { - errorMessage = chrome.i18n.getMessage(xmlhttp.status); - } else { - errorMessage = chrome.i18n.getMessage("connectionError") + xmlhttp.status; - } - - SB.setUsernameStatus.innerText = errorMessage; + SB.setUsernameStatus.innerText = getErrorMessageI(xmlhttp.status); } }); }); @@ -1224,12 +1205,7 @@ function runThePopup() { //failure: duplicate vote addVoteMessage(chrome.i18n.getMessage("voteFail"), UUID) } else if (response.successType == -1) { - if (response.statusCode == 502) { - addVoteMessage(chrome.i18n.getMessage("serverDown"), UUID) - } else { - //failure: unknown error - addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) - } + addVoteMessage(getErrorMessage(response.statusCode), UUID) } } }); diff --git a/utils.js b/utils.js index d9ce3a22..379814cd 100644 --- a/utils.js +++ b/utils.js @@ -66,3 +66,24 @@ function localizeHtmlPage() { } } +/** + * Gets the error message in a nice string + * + * @param {int} statusCode + * @returns {string} errorMessage + */ +function getErrorMessage(statusCode) { + let errorMessage = ""; + + if([400, 429, 409, 502, 0].includes(statusCode)) { + //treat them the same + if (statusCode == 503) statusCode = 502; + + errorMessage = chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode + + "\n\n" + chrome.i18n.getMessage("statusReminder"); + } else { + errorMessage = chrome.i18n.getMessage("connectionError") + statusCode; + } + + return errorMessage; +} \ No newline at end of file From a5baebab3fe04bfab79f61e2a6c1583e781a90dc Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 13 Dec 2019 21:55:43 -0500 Subject: [PATCH 5/9] Fixed new submissions getting added to the downloaded submissions. --- background.js | 20 +------------------- content.js | 15 ++++++++++++--- utils.js | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/background.js b/background.js index 3961009b..ae1f7e45 100644 --- a/background.js +++ b/background.js @@ -215,22 +215,4 @@ function sendRequestToServer(type, address, callback) { //submit this request xmlhttp.send(); -} - -function generateUserID(length = 36) { - let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - let result = ""; - if (window.crypto && window.crypto.getRandomValues) { - values = new Uint32Array(length); - window.crypto.getRandomValues(values); - for (i = 0; i < length; i++) { - result += charset[values[i] % charset.length]; - } - return result; - } else { - for (let i = 0; i < length; i++) { - result += charset[Math.floor(Math.random() * charset.length)]; - } - return result; - } -} +} \ No newline at end of file diff --git a/content.js b/content.js index c509e6cc..8547342f 100644 --- a/content.js +++ b/content.js @@ -1041,6 +1041,9 @@ function submitSponsorTimes() { //update sponsorTimes chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes}); + //update sponsorTimesSubmitting + sponsorTimesSubmitting = sponsorTimes; + let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes) + "\n\n" + chrome.i18n.getMessage("confirmMSG") + "\n\n" + chrome.i18n.getMessage("guildlinesSummary"); if(!confirm(confirmMessage)) return; @@ -1060,8 +1063,6 @@ function sendSubmitMessage(){ let currentVideoID = sponsorVideoID; - let currentSponsorTimes = submitSponsorTimes; - chrome.runtime.sendMessage({ message: "submitTimes", videoID: currentVideoID @@ -1085,11 +1086,19 @@ function sendSubmitMessage(){ //clear the sponsor times let sponsorTimeKey = "sponsorTimes" + currentVideoID; - chrome.storage.sync.set({[sponsorTimeKey]: []}, () => void updatePreviewBar()); + chrome.storage.sync.set({[sponsorTimeKey]: []}); //add submissions to current sponsors list sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting); + for (let i = 0; i < sponsorTimesSubmitting.length; i++) { + // Add some random IDs + UUIDs.push(generateUserID()); + } + + // Empty the submitting times sponsorTimesSubmitting = []; + + updatePreviewBar(); } else { //show that the upload failed document.getElementById("submitButton").style.animation = "unset"; diff --git a/utils.js b/utils.js index 379814cd..838769a2 100644 --- a/utils.js +++ b/utils.js @@ -66,6 +66,24 @@ function localizeHtmlPage() { } } +function generateUserID(length = 36) { + let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + let result = ""; + if (window.crypto && window.crypto.getRandomValues) { + values = new Uint32Array(length); + window.crypto.getRandomValues(values); + for (i = 0; i < length; i++) { + result += charset[values[i] % charset.length]; + } + return result; + } else { + for (let i = 0; i < length; i++) { + result += charset[Math.floor(Math.random() * charset.length)]; + } + return result; + } +} + /** * Gets the error message in a nice string * From 369364f5742232a6b515c1b7290c259e152a57f3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 13 Dec 2019 22:38:00 -0500 Subject: [PATCH 6/9] Fixed downvoted sponsors reappearing. --- content.js | 7 ++++++- utils/previewBar.js | 2 ++ utils/skipNotice.js | 10 +--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/content.js b/content.js index 8547342f..8a22c0a9 100644 --- a/content.js +++ b/content.js @@ -479,7 +479,12 @@ function updatePreviewBar() { //create an array of the sponsor types let types = []; for (let i = 0; i < localSponsorTimes.length; i++) { - types.push("sponsor"); + if (!hiddenSponsorTimes.includes(i)) { + types.push("sponsor"); + } else { + // Don't show this sponsor + types.push(null); + } } for (let i = 0; i < sponsorTimesSubmitting.length; i++) { types.push("previewSponsor"); diff --git a/utils/previewBar.js b/utils/previewBar.js index c746c5d4..e5a74b62 100644 --- a/utils/previewBar.js +++ b/utils/previewBar.js @@ -59,6 +59,8 @@ class PreviewBar { duration = Math.floor(duration * 100) / 100; let width; for (let i = 0; i < timestamps.length; i++) { + if (types[i] == null) continue; + width = (timestamps[i][1] - timestamps[i][0]) / duration * 100; width = Math.floor(width * 100) / 100; diff --git a/utils/skipNotice.js b/utils/skipNotice.js index c69e62d2..a9e537b3 100644 --- a/utils/skipNotice.js +++ b/utils/skipNotice.js @@ -324,15 +324,7 @@ class SkipNotice { //add this as a hidden sponsorTime hiddenSponsorTimes.push(i); - let sponsorTimesLeft = sponsorTimes.slice(); - for (let j = 0; j < hiddenSponsorTimes.length; j++) { - //remove this sponsor time - sponsorTimesLeft.splice(hiddenSponsorTimes[j], 1); - } - - //update the preview - previewBar.set(sponsorTimesLeft, [], v.duration); - + updatePreviewBar(); break; } } From b42bdc6e6f21eb76ea8afe5b7983d049f173d314 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 13 Dec 2019 22:45:40 -0500 Subject: [PATCH 7/9] Fixed popup stats padding. --- popup.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/popup.html b/popup.html index 3e96de4d..a9130680 100644 --- a/popup.html +++ b/popup.html @@ -140,24 +140,24 @@ __MSG_youHaveSavedTimeEnd__ -
-
- -