From 36d7dcce9bd945b429a34560b65f58e7192f33b2 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 15:17:31 -0500 Subject: [PATCH 1/9] Revert "Removed snopyta.org from the default." This reverts commit fb974de53b50e56f6aa464775aa7758fa7efe386. --- SB.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SB.js b/SB.js index 9fa8f29e..aeb524dc 100644 --- a/SB.js +++ b/SB.js @@ -160,7 +160,7 @@ SB.defaults = { "hideDeleteButtonPlayerControls": false, "hideDiscordLaunches": 0, "hideDiscordLink": false, - "invidiousInstances": ["invidio.us", "invidiou.sh"] + "invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"] } // Reset config From dce90e86bf758fdc1d7bee20e52c1e4108d35f40 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 15:46:50 -0500 Subject: [PATCH 2/9] Added invidious support info to the help page. --- help/index_en.html | 6 ++++++ help/styles.css | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/help/index_en.html b/help/index_en.html index 5db3c81f..abeff075 100644 --- a/help/index_en.html +++ b/help/index_en.html @@ -27,6 +27,12 @@ Come contribute, make some suggestions and help out in the Discord: https://discord.gg/QnmVMpU

+ Enable Invidious Support + +

+ Invidious is a third-party YouTube viewer. SponsorBlock now supports invidious along with YouTube. Please visit the options page to make sure everything is how you want it to be. +

+

How skipping works

diff --git a/help/styles.css b/help/styles.css index 278d8c72..b71059d3 100644 --- a/help/styles.css +++ b/help/styles.css @@ -1,4 +1,8 @@ -:not(.hljs-keyword):not(.hljs-comment):not(.hljs-number):not(.hljs-string):not(pre):not(code) { +.bigText { + font-size: 50px; +} + +body { background-color: #333333; } @@ -122,7 +126,7 @@ a { text-decoration: none; } -p,li { +p,li,a { font-family: sans-serif; font-size: 20; color: #c4c4c4; From 5c227f445af664be270190afe9629ad552d6479a Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 19:58:59 -0500 Subject: [PATCH 3/9] Added ublock origin to npm run dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2300f120..c5dadd4a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "dev": "web-ext run", + "dev": "web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm", "build": "web-ext build --overwrite-dest -i \"*(package-lock.json|README.md|package.json|config.js.example|firefox_manifest-extra.json|manifest.json.original|ignored|crowdin.yml)\"" }, "repository": { From 7335429541899e62dc142f565fe88bfa3cedcfde Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 20:06:16 -0500 Subject: [PATCH 4/9] Added option for auto-vote. --- SB.js | 3 ++- _locales/en/messages.json | 6 ++++++ content.js | 3 ++- options/options.html | 17 +++++++++++++++++ popup.js | 3 --- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/SB.js b/SB.js index aeb524dc..0e0f82e1 100644 --- a/SB.js +++ b/SB.js @@ -160,7 +160,8 @@ SB.defaults = { "hideDeleteButtonPlayerControls": false, "hideDiscordLaunches": 0, "hideDiscordLink": false, - "invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"] + "invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"], + "autoUpvote": true } // Reset config diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3dca55b5..4157ae1c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -374,5 +374,11 @@ }, "currentInstances": { "message": "Current Instances:" + }, + "enableAutoUpvote": { + "message": "Auto Upvote" + }, + "whatAutoUpvote": { + "message": "With this enabled, the extension will upvote all submissions you view if you do not report them. If the notice is disabled, this will not occur." } } diff --git a/content.js b/content.js index b165dafd..1d85de16 100644 --- a/content.js +++ b/content.js @@ -556,8 +556,9 @@ function skipToTime(v, index, sponsorTimes, openNotice) { //send out the message saying that a sponsor message was skipped if (!SB.config.dontShowNotice) { let skipNotice = new SkipNotice(this, currentUUID, SB.config.disableAutoSkip); + //auto-upvote this sponsor - if (SB.config.trackViewCount && !SB.config.disableAutoSkip) { + if (SB.config.trackViewCount && !SB.config.disableAutoSkip && SB.config.autoUpvote) { vote(1, currentUUID, null); } } diff --git a/options/options.html b/options/options.html index b76c3e0a..2278e4d3 100644 --- a/options/options.html +++ b/options/options.html @@ -181,6 +181,23 @@

__MSG_whatDeleteButton__
+ +
+
+ +
+ + +
+
+ +
__MSG_whatAutoUpvote__
+


diff --git a/popup.js b/popup.js index 9e9ccaeb..7be8235d 100644 --- a/popup.js +++ b/popup.js @@ -231,7 +231,6 @@ async function runThePopup() { } //load video times for this video - setTimeout(()=> console.log( SB.config.sponsorTimes.set), 200 ) let sponsorTimesStorage = SB.config.sponsorTimes.get(currentVideoID); if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) { if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) { @@ -919,10 +918,8 @@ async function runThePopup() { type: type, UUID: UUID }, function(response) { - console.log(response) if (response != undefined) { //see if it was a success or failure - console.log(response) if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) { //success (treat rate limits as a success) addVoteMessage(chrome.i18n.getMessage("voted"), UUID) From 9e8a520d1ed475dbe8f1c91ad6f731924773c85c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 20:48:16 -0500 Subject: [PATCH 5/9] Fixed broken voting. --- background.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/background.js b/background.js index f6d1d533..904e46d9 100644 --- a/background.js +++ b/background.js @@ -16,9 +16,7 @@ chrome.tabs.onUpdated.addListener(function(tabId) { }, () => void chrome.runtime.lastError ); // Suppress error on Firefox }); -chrome.runtime.onMessage.addListener(async function (request, sender, callback) { - await wait(() => SB.config !== undefined); - +chrome.runtime.onMessage.addListener(function (request, sender, callback) { switch(request.message) { case "submitTimes": submitTimes(request.videoID, callback); From 4f8e1bc8273aa96a7152fb76b37a6e0a1cbf8597 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 20:49:21 -0500 Subject: [PATCH 6/9] Fixed formatting. --- background.js | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/background.js b/background.js index 904e46d9..7dcbd61d 100644 --- a/background.js +++ b/background.js @@ -130,34 +130,35 @@ function addSponsorTime(time, videoID, callback) { } function submitVote(type, UUID, callback) { - let userID = SB.config.userID; + let userID = SB.config.userID; - if (userID == undefined || userID === "undefined") { - //generate one - userID = generateUserID(); - SB.config.userID = userID; + if (userID == undefined || userID === "undefined") { + //generate one + userID = generateUserID(); + SB.config.userID = userID; + } + + //publish this vote + sendRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { + callback({ + successType: 1 + }); + } else if (xmlhttp.readyState == 4 && xmlhttp.status == 405) { + //duplicate vote + callback({ + successType: 0, + statusCode: xmlhttp.status + }); + } else if (error) { + //error while connect + callback({ + successType: -1, + statusCode: xmlhttp.status + }); } - //publish this vote - sendRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) { - if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { - callback({ - successType: 1 - }); - } else if (xmlhttp.readyState == 4 && xmlhttp.status == 405) { - //duplicate vote - callback({ - successType: 0, - statusCode: xmlhttp.status - }); - } else if (error) { - //error while connect - callback({ - successType: -1, - statusCode: xmlhttp.status - }); - } - }) + }); } async function submitTimes(videoID, callback) { From 259f7a94392bf3ae523e9f8fdf0fd5ad87799d59 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 22:15:28 -0500 Subject: [PATCH 7/9] Added notice info about the Invidious update. TODO: remove this in the future. --- SB.js | 1 + _locales/en/messages.json | 6 ++++++ background.js | 6 +++++- content.js | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/SB.js b/SB.js index 0e0f82e1..a7f8d048 100644 --- a/SB.js +++ b/SB.js @@ -161,6 +161,7 @@ SB.defaults = { "hideDiscordLaunches": 0, "hideDiscordLink": false, "invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"], + "invidiousUpdateInfoShowCount": 0, "autoUpvote": true } diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 4157ae1c..eab70b4e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -380,5 +380,11 @@ }, "whatAutoUpvote": { "message": "With this enabled, the extension will upvote all submissions you view if you do not report them. If the notice is disabled, this will not occur." + }, + "invidiousInfo1": { + "message": "Invidious (the 3rd party YouTube site) support has been added!" + }, + "invidiousInfo2": { + "message": "You MUST enable it in the options for it to work." } } diff --git a/background.js b/background.js index 7dcbd61d..0227ef19 100644 --- a/background.js +++ b/background.js @@ -74,7 +74,11 @@ chrome.runtime.onInstalled.addListener(function (object) { //generate a userID const newUserID = generateUserID(); //save this UUID - SB.config.userID = newUserID; + SB.config.userID = newUserID; + + //TODO: Remove when invidious support is old + // Don't show this to new users + SB.config.invidiousUpdateInfoShowCount = 6; } }, 1500); }); diff --git a/content.js b/content.js index 1d85de16..f3b96fe0 100644 --- a/content.js +++ b/content.js @@ -557,6 +557,13 @@ function skipToTime(v, index, sponsorTimes, openNotice) { if (!SB.config.dontShowNotice) { let skipNotice = new SkipNotice(this, currentUUID, SB.config.disableAutoSkip); + //TODO: Remove this when Invidious support is old + if (SB.config.invidiousUpdateInfoShowCount < 5) { + skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("invidiousInfo1"), chrome.i18n.getMessage("invidiousInfo2")); + + SB.config.invidiousUpdateInfoShowCount += 1; + } + //auto-upvote this sponsor if (SB.config.trackViewCount && !SB.config.disableAutoSkip && SB.config.autoUpvote) { vote(1, currentUUID, null); From 968df5a2e4c3f9bd8acd36afdf2fcbe9bafe4ffa Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 22:15:42 -0500 Subject: [PATCH 8/9] Increased notice width --- content.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content.css b/content.css index 525fedc3..c76484ad 100644 --- a/content.css +++ b/content.css @@ -71,7 +71,7 @@ } .sponsorSkipNotice { - min-width: 300px; + min-width: 350px; background-color: rgba(28, 28, 28, 0.9); position: absolute; right: 5px; From 36c4ebda65d24e5eaeefac92e17df9e56d6f5186 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 10 Jan 2020 22:16:53 -0500 Subject: [PATCH 9/9] Added comments to the settimeout on install --- background.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/background.js b/background.js index 0227ef19..1f7cdd70 100644 --- a/background.js +++ b/background.js @@ -63,6 +63,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { //add help page on install chrome.runtime.onInstalled.addListener(function (object) { + // This let's the config sync to run fully before checking. + // This is required on Firefox setTimeout(function() { const userID = SB.config.userID;