From 04190b27d8eb768789d9984f7db37ecd4eb0456b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 24 Sep 2019 17:55:07 -0400 Subject: [PATCH 1/9] Made it ignore rate limits for voting. --- content.js | 4 ++-- popup.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/content.js b/content.js index fb0b13b0..b41bf2fe 100644 --- a/content.js +++ b/content.js @@ -879,8 +879,8 @@ function vote(type, UUID, skipNotice) { if (response != undefined) { //see if it was a success or failure if (skipNotice != null) { - if (response.successType == 1) { - //success + if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) { + //success (treat rate limits as a success) if (type == 0) { skipNotice.afterDownvote.bind(skipNotice)(); } diff --git a/popup.js b/popup.js index 3476747a..a7b3a41a 100644 --- a/popup.js +++ b/popup.js @@ -1102,8 +1102,8 @@ function runThePopup() { }, function(response) { if (response != undefined) { //see if it was a success or failure - if (response.successType == 1) { - //success + if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) { + //success (treat rate limits as a success) addVoteMessage(chrome.i18n.getMessage("voted"), UUID) } else if (response.successType == 0) { //failure: duplicate vote From 563610cbcd2d738ecb93179d837a0d1fa88a843f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 24 Sep 2019 18:16:57 -0400 Subject: [PATCH 2/9] Made it show the new notice again. --- _locales/en/messages.json | 4 ++++ content.js | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index c373b7b3..4d47360e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -243,5 +243,9 @@ "sourceCode": { "message": "Source Code", "description": "Used on Firefox Store Page" + }, + "noticeUpdate": { + "message": "The notice has been upgraded! If you still don't like it, hit the never show button.", + "description": "The message displayed after the notice was upgraded." } } diff --git a/content.js b/content.js index b41bf2fe..ad957aa8 100644 --- a/content.js +++ b/content.js @@ -80,13 +80,22 @@ chrome.storage.sync.get(["trackViewCount"], function(result) { //if the notice should not be shown //happens when the user click's the "Don't show notice again" button +//option renamed when new notice was made var dontShowNotice = false; -chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { +chrome.storage.sync.get(["dontShowNotice"], function(result) { let dontShowNoticeAgain = result.dontShowNoticeAgain; if (dontShowNoticeAgain != undefined) { dontShowNotice = dontShowNoticeAgain; } }); +//load the legacy option to hide the notice +var dontShowNoticeOld = false; +chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { + let dontShowNoticeAgain = result.dontShowNoticeAgain; + if (dontShowNoticeAgain != undefined) { + dontShowNoticeOld = dontShowNoticeAgain; + } +}); //get messages from the background script and the popup chrome.runtime.onMessage.addListener(messageListener); @@ -591,7 +600,15 @@ function skipToTime(v, index, sponsorTimes, openNotice) { if (openNotice) { //send out the message saying that a sponsor message was skipped if (!dontShowNotice) { - new SkipNotice(this, currentUUID); + let skipNotice = new SkipNotice(this, currentUUID); + + if (dontShowNoticeOld) { + //show why this notice is showing + skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("noticeUpdate")); + + //disable this setting + chrome.storage.sync.set({"dontShowNoticeAgain": false}); + } //auto-upvote this sponsor if (trackViewCount) { @@ -912,7 +929,7 @@ function closeAllSkipNotices(){ } function dontShowNoticeAgain() { - chrome.storage.sync.set({"dontShowNoticeAgain": true}); + chrome.storage.sync.set({"dontShowNotice": true}); dontShowNotice = true; From 8bb8511bf42270aff5e8db597a3cf9c5b02b9d46 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 24 Sep 2019 18:21:47 -0400 Subject: [PATCH 3/9] Fixed indenting. --- content.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/content.js b/content.js index ad957aa8..5283354c 100644 --- a/content.js +++ b/content.js @@ -937,15 +937,15 @@ function dontShowNoticeAgain() { } function sponsorMessageStarted(callback) { - v = document.querySelector('video'); + v = document.querySelector('video'); - //send back current time - callback({ - time: v.currentTime - }) + //send back current time + callback({ + time: v.currentTime + }) - //update button - toggleStartSponsorButton(); + //update button + toggleStartSponsorButton(); } function submitSponsorTimes() { From 685147054710dbb81ce2404a24a56d50cdf97d52 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 28 Oct 2019 16:13:37 -0400 Subject: [PATCH 4/9] Added the ability to change the keybind. --- _locales/en/messages.json | 12 ++++++++++++ content.js | 20 +++++++++++++++++--- popup.html | 13 +++++++++++++ popup.js | 39 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 80 insertions(+), 4 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 488ba60f..ddb91234 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -246,5 +246,17 @@ "noticeUpdate": { "message": "The notice has been upgraded! If you still don't like it, hit the never show button.", "description": "The message displayed after the notice was upgraded." + }, + "setStartSponsorShortcut": { + "message": "Set key for start sponsor keybind" + }, + "setSubmitKeybind": { + "message": "Set key for submission keybind" + }, + "keybindDescription": { + "message": "Select a key by typing it" + }, + "keybindDescriptionComplete": { + "message": "The keybind has been set to: " } } diff --git a/content.js b/content.js index 5283354c..7b3fbc09 100644 --- a/content.js +++ b/content.js @@ -204,18 +204,32 @@ function messageListener(request, sender, sendResponse) { } //check for hotkey pressed -document.onkeydown = function(e){ +document.onkeydown = async function(e){ e = e || window.event; var key = e.key; let video = document.getElementById("movie_player"); + let startSponsorKey = await new Promise((resolve, reject) => { + chrome.storage.sync.get(["startSponsorKeybind"], (result) => resolve(result)); + }); + let submitKey = await new Promise((resolve, reject) => { + chrome.storage.sync.get(["submitKeybind"], (result) => resolve(result)); + }); + + if (startSponsorKey.startSponsorKeybind === undefined) { + startSponsorKey.startSponsorKeybind = ";" + } + if (submitKey.submitKeybind === undefined) { + submitKey.submitKeybind = "'" + } + //is the video in focus, otherwise they could be typing a comment if (document.activeElement === video) { - if(key == ';'){ + if(key == startSponsorKey.startSponsorKeybind){ //semicolon startSponsorClicked(); - } else if (key == "'") { + } else if (key == submitKey.submitKeybind) { //single quote submitSponsorTimes(); } diff --git a/popup.html b/popup.html index ac89c9b5..a2923eb0 100644 --- a/popup.html +++ b/popup.html @@ -172,6 +172,19 @@

__MSG_Options__

+ + + +
+
+ +
+
+ + + +
+
diff --git a/popup.js b/popup.js index a7b3a41a..feadd2ab 100644 --- a/popup.js +++ b/popup.js @@ -70,6 +70,10 @@ function runThePopup() { "videoFound", "sponsorMessageTimes", "downloadedSponsorMessageTimes", + // Keybinds + "setStartSponsorKeybind", + "setSubmitKeybind", + "keybindDescription" ].forEach(id => SB[id] = document.getElementById(id)); //setup click listeners @@ -79,6 +83,8 @@ function runThePopup() { SB.clearTimes.addEventListener("click", clearTimes); SB.submitTimes.addEventListener("click", submitTimes); SB.showNoticeAgain.addEventListener("click", showNoticeAgain); + SB.setStartSponsorKeybind.addEventListener("click", () => setKeybind(true)); + SB.setSubmitKeybind.addEventListener("click", () => setKeybind(false)); SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls); SB.showVideoPlayerControls.addEventListener("click", showVideoPlayerControls); SB.hideInfoButtonPlayerControls.addEventListener("click", hideInfoButtonPlayerControls); @@ -104,6 +110,9 @@ function runThePopup() { //is this a YouTube tab? let isYouTubeTab = false; + + // Is the start sponsor keybind currently being set + let setStartSponsorKeybind = false; //see if discord link can be shown chrome.storage.sync.get(["hideDiscordLink"], function(result) { @@ -1236,7 +1245,35 @@ function runThePopup() { ); }); } - + + function setKeybind(startSponsorKeybind) { + document.getElementById("keybindButtons").style.display = "none"; + + document.getElementById("keybindDescription").style.display = "initial"; + document.getElementById("keybindDescription").innerText = chrome.i18n.getMessage("keybindDescription"); + + setStartSponsorKeybind = startSponsorKeybind; + + document.addEventListener("keydown", onKeybindSet) + } + + function onKeybindSet(e) { + e = e || window.event; + var key = e.key; + + if (setStartSponsorKeybind) { + chrome.storage.sync.set({"startSponsorKeybind": key}); + } else { + chrome.storage.sync.set({"submitKeybind": key}); + } + + document.removeEventListener("keydown", onKeybindSet); + + document.getElementById("keybindDescription").innerText = chrome.i18n.getMessage("keybindDescriptionComplete") + " " + key; + + document.getElementById("keybindButtons").style.display = "unset"; + } + //converts time in seconds to minutes function getTimeInMinutes(seconds) { let minutes = Math.floor(seconds / 60); From 25b9edabf8e964cb3ec70b80a75ae8f315bfe934 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 28 Oct 2019 16:16:13 -0400 Subject: [PATCH 5/9] Changed hint to say that you can change the keybind. --- _locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ddb91234..07e175a2 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -166,7 +166,7 @@ "message": "Click the button below when the sponsorship starts and ends to record and\nsubmit it to the database." }, "popupHint": { - "message": "Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit." + "message": "Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit. (This can be changed in the options)" }, "lastTimes": { "message": "Latest Sponsor Message Times Chosen" From 4e4d50de827dc20f0f51116cf8e82fe36aff1d66 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 30 Oct 2019 23:30:30 -0400 Subject: [PATCH 6/9] Fixed feature to show the notice to users again. --- _locales/en/messages.json | 8 ++++++-- content.js | 7 ++++--- popup.js | 8 ++++---- utils/skipNotice.js | 27 +++++++++++++++++++++++---- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 07e175a2..3fccef75 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -244,8 +244,12 @@ "description": "Used on Firefox Store Page" }, "noticeUpdate": { - "message": "The notice has been upgraded! If you still don't like it, hit the never show button.", - "description": "The message displayed after the notice was upgraded." + "message": "The notice has been upgraded!", + "description": "The first line of the message displayed after the notice was upgraded." + }, + "noticeUpdate2": { + "message": "If you still don't like it, hit the never show button.", + "description": "The second line of the message displayed after the notice was upgraded." }, "setStartSponsorShortcut": { "message": "Set key for start sponsor keybind" diff --git a/content.js b/content.js index 7b3fbc09..f0db497b 100644 --- a/content.js +++ b/content.js @@ -618,10 +618,11 @@ function skipToTime(v, index, sponsorTimes, openNotice) { if (dontShowNoticeOld) { //show why this notice is showing - skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("noticeUpdate")); + skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("noticeUpdate"), chrome.i18n.getMessage("noticeUpdate2")); - //disable this setting - chrome.storage.sync.set({"dontShowNoticeAgain": false}); + //remove this setting + chrome.storage.sync.remove(["dontShowNoticeAgain"]); + dontShowNoticeOld = false; } //auto-upvote this sponsor diff --git a/popup.js b/popup.js index feadd2ab..5dfaadda 100644 --- a/popup.js +++ b/popup.js @@ -136,9 +136,9 @@ function runThePopup() { //if the don't show notice again letiable is true, an option to // disable should be available - chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { - let dontShowNoticeAgain = result.dontShowNoticeAgain; - if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) { + chrome.storage.sync.get(["dontShowNotice"], function(result) { + let dontShowNotice = result.dontShowNotice; + if (dontShowNotice != undefined && dontShowNotice) { SB.showNoticeAgain.style.display = "unset"; } }); @@ -828,7 +828,7 @@ function runThePopup() { } function showNoticeAgain() { - chrome.storage.sync.set({"dontShowNoticeAgain": false}); + chrome.storage.sync.set({"dontShowNotice": false}); chrome.tabs.query({ active: true, diff --git a/utils/skipNotice.js b/utils/skipNotice.js index 511baf4a..4e35cc7b 100644 --- a/utils/skipNotice.js +++ b/utils/skipNotice.js @@ -294,21 +294,37 @@ class SkipNotice { } } - addNoticeInfoMessage(message) { + addNoticeInfoMessage(message, message2) { let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix); if (previousInfoMessage != null) { //remove it document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage); } + + let previousInfoMessage2 = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix + "2"); + if (previousInfoMessage2 != null) { + //remove it + document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage2); + } //add info let thanksForVotingText = document.createElement("p"); thanksForVotingText.id = "sponsorTimesInfoMessage" + this.idSuffix; thanksForVotingText.className = "sponsorTimesInfoMessage"; thanksForVotingText.innerText = message; - + //add element to div document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix)); + + if (message2 !== undefined) { + let thanksForVotingText2 = document.createElement("p"); + thanksForVotingText2.id = "sponsorTimesInfoMessage" + this.idSuffix + "2"; + thanksForVotingText2.className = "sponsorTimesInfoMessage"; + thanksForVotingText2.innerText = message2; + + //add element to div + document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText2, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix)); + } } resetNoticeInfoMessage() { @@ -337,7 +353,7 @@ class SkipNotice { thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix; thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage"; thanksForVotingText.innerText = message; - + //add element to div document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText); } @@ -348,13 +364,16 @@ class SkipNotice { //remove it document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage); } - + //show button again document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display"); } //close this notice close() { + //reset message + this.resetNoticeInfoMessage(); + let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix); if (notice != null) { notice.remove(); From 69c93a0563c29d98017809306b3cbfb5a7adbec7 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 30 Oct 2019 23:32:32 -0400 Subject: [PATCH 7/9] Removed deprecated show install page code --- background.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/background.js b/background.js index 28fd6bb0..2280acd3 100644 --- a/background.js +++ b/background.js @@ -42,28 +42,13 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { //add help page on install chrome.runtime.onInstalled.addListener(function (object) { - // TODO (shownInstallPage): remove shownInstallPage logic after sufficient amount of time, - // so that people have time to upgrade and move to shownInstallPage-free code. chrome.storage.sync.get(["userID", "shownInstallPage"], function(result) { const userID = result.userID; - // TODO (shownInstallPage): delete row below - const shownInstallPage = result.shownInstallPage; // If there is no userID, then it is the first install. if (!userID){ - // Show install page, if there is no user id - // and there is no shownInstallPage. - // TODO (shownInstallPage): remove this if statement, but leave contents - if (!shownInstallPage){ - //open up the install page - chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))}); - } - - // TODO (shownInstallPage): delete if statement and contents - // If shownInstallPage is set, remove it. - if (!!shownInstallPage){ - chrome.storage.sync.remove("shownInstallPage"); - } + //open up the install page + chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))}); //generate a userID const newUserID = generateUserID(); From 784ddea34a1974e51290321a81f28bc1f2b99dd3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 30 Oct 2019 23:33:10 -0400 Subject: [PATCH 8/9] Updated version number. --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 10778193..e7fae867 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.1.9", + "version": "1.1.9.1", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [ From 1791d316813890aaf21997af9e0047ca2961642a Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Wed, 30 Oct 2019 23:37:36 -0400 Subject: [PATCH 9/9] Revert "Moved browser specific settings into manifest" This reverts commit 047432af033716cdf981628d3472bd0349afae64. --- firefox_manifest-extra.json | 8 ++++++++ manifest.json | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 firefox_manifest-extra.json diff --git a/firefox_manifest-extra.json b/firefox_manifest-extra.json new file mode 100644 index 00000000..7625cd66 --- /dev/null +++ b/firefox_manifest-extra.json @@ -0,0 +1,8 @@ +{ + "browser_specific_settings": { + "gecko": { + "id": "sponsorBlocker@ajay.app", + "strict_min_version": "57.0" + } + } +} diff --git a/manifest.json b/manifest.json index 494ac8b0..10778193 100644 --- a/manifest.json +++ b/manifest.json @@ -65,11 +65,5 @@ "128": "icons/LogoSponsorBlocker128px.png", "256": "icons/LogoSponsorBlocker256px.png" }, - "browser_specific_settings": { - "gecko": { - "id": "sponsorBlocker@ajay.app", - "strict_min_version": "57.0" - } - }, "manifest_version": 2 }