From f2404168860966e6b00ec255b89dd23452c0be13 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 23 Nov 2019 14:35:33 -0500 Subject: [PATCH 1/7] Fixed reversed strings. Resolves https://github.com/ajayyy/SponsorBlock/issues/170. --- _locales/en/messages.json | 4 ++-- _locales/fr/messages.json | 4 ++-- _locales/it/messages.json | 4 ++-- _locales/pt_BR/messages.json | 4 ++-- _locales/pt_pt/messages.json | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 42256bb1..cbfed2b0 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -193,10 +193,10 @@ "message": "Options" }, "showButtons": { - "message": "Hide Buttons On YouTube Player" + "message": "Show Buttons On YouTube Player" }, "hideButtons": { - "message": "Show Buttons On YouTube Player" + "message": "Hide Buttons On YouTube Player" }, "hideButtonsDescription": { "message": "This hides the buttons that appear on the YouTube player to submit sponsors. I can see this being annoying for some\n people. Instead of using the button there, this popup can be used to submit sponsors. To hide the notice that appears, \n use the button that appears on the notice saying \"Don't show this again\". You can always enable these settings again later." diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 37d31dc2..b9749c06 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -193,10 +193,10 @@ "message": "Options" }, "showButtons": { - "message": "Cacher les boutons sur le lecteur YouTube" + "message": "Montrer les boutons sur le lecteur YouTube" }, "hideButtons": { - "message": "Montrer les boutons sur le lecteur YouTube" + "message": "Cacher les boutons sur le lecteur YouTube" }, "hideButtonsDescription": { "message": "Cela permet de cacher du lecteur YouTube les boutons utilisés pour soumettre des segments commerciaux. Je peux \ncomprendre que certaines personnes les trouvent perturbants. Au lieu d'utiliser ces boutons, cette fenêtre peut être utilisée \npour soumettre des segments commerciaux. Pour cacher la notification, utilisez le bouton \"Ne plus montrer\" sur la notification. Vous pouvez toujours réactiver ces paramètres plus tard." diff --git a/_locales/it/messages.json b/_locales/it/messages.json index 6aa34301..053da4ee 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -194,10 +194,10 @@ "message": "Opzioni" }, "showButtons": { - "message": "Nascondi i Pulsanti nel Lettore di YouTube" + "message": "Mostra i Pulsanti nel Lettore di YouTube" }, "hideButtons": { - "message": "Mostra i Pulsanti nel Lettore di YouTube" + "message": "Nascondi i Pulsanti nel Lettore di YouTube" }, "hideButtonsDescription": { "message": "Nasconde i pulsanti che appaiono nel lettore di YouTube per inviare spezzoni sponsorizzati. Capisco che può essere fastidioso per alcune\n persone. Invece di utilizzare quei pulsanti, è possibile utilizzare questo popup per inviare gli spezzoni sponsorizzati. Per nascondere l'avviso che appare, \nusa il bottone \"Non mostrare più\" nell'avviso. Potrai sempre abilitare nuovamente queste impostazioni in futuro." diff --git a/_locales/pt_BR/messages.json b/_locales/pt_BR/messages.json index bae0e462..0cbcfd8b 100644 --- a/_locales/pt_BR/messages.json +++ b/_locales/pt_BR/messages.json @@ -194,10 +194,10 @@ "message": "Opções" }, "showButtons": { - "message": "Esconder botões no player do Youtube" + "message": "Mostrar botões no player do Youtube" }, "hideButtons": { - "message": "Mostrar botões no player do Youtube" + "message": "Esconder botões no player do Youtube" }, "hideButtonsDescription": { "message": "Isto esconde os botões que aparecem no player do Youtube para submeter patrocínios. Entendemos que possa ser\n incómodo a algumas pessoas. Em vez de usar esses botões pode usar os do popup. Para esconder a mensagem que aparece, \n ususe o botão na mesma que diz \"Don't show this again\". Pode sempre reactivar estas definições novamente." diff --git a/_locales/pt_pt/messages.json b/_locales/pt_pt/messages.json index 18aae20b..26e8ea38 100644 --- a/_locales/pt_pt/messages.json +++ b/_locales/pt_pt/messages.json @@ -193,10 +193,10 @@ "message": "Opções" }, "showButtons": { - "message": "Esconder botões no player do Youtube" + "message": "Mostrar botões no player do Youtube" }, "hideButtons": { - "message": "Mostrar botões no player do Youtube" + "message": "Esconder botões no player do Youtube" }, "hideButtonsDescription": { "message": "Isto esconde os botões que aparecem no player do Youtube para submeter patrocínios. Entendemos que possa ser\n incómodo a algumas pessoas. Em vez de usar esses botões pode usar os do popup. Para esconder a mensagem que aparece, \n ususe o botão na mesma que diz \"Don't show this again\". Pode sempre reactivar estas definições novamente." From 2fa412e5744e5cee578527cabed334210b5b593b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 23 Nov 2019 17:44:22 -0500 Subject: [PATCH 2/7] Removed deprecated code to fix whitelist array. --- content.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/content.js b/content.js index ec55863b..a1ad6950 100644 --- a/content.js +++ b/content.js @@ -525,23 +525,6 @@ function whitelistCheck() { UUIDs = []; channelWhitelisted = true; - - //make sure the whitelistedChannels array isn't broken and full of null entries - //TODO: remove this at some point in the future as the bug that caused this should be patched - if (whitelistedChannels.some((el) => el === null)) { - //remove the entries that are null - let cleanWhitelistedChannelsArray = []; - for (let i = 0; i < whitelistedChannels.length; i++) { - let channelURL = whitelistedChannels[i]; - if (channelURL !== null) { - //add it - cleanWhitelistedChannelsArray.push(channelURL); - } - } - - //save this value - chrome.storage.sync.set({"whitelistedChannels": cleanWhitelistedChannelsArray}); - } } }); } From 0a84dbd3a51924ec4b4d376b8fd5faf4de7aecd5 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 23 Nov 2019 17:53:04 -0500 Subject: [PATCH 3/7] Improved speed of whitelist check. --- content.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/content.js b/content.js index a1ad6950..2e55d804 100644 --- a/content.js +++ b/content.js @@ -378,6 +378,18 @@ function sponsorsLookup(id, channelIDPromise) { v.addEventListener('durationchange', updatePreviewBar); } + if (channelIDPromise != null) { + if (channelIDPromise.isFulfilled) { + whitelistCheck(); + } else if (channelIDPromise.isRejected) { + //try again + wait(getChannelID).then(whitelistCheck).catch(); + } else { + //add it as a then statement + channelIDPromise.then(whitelistCheck); + } + } + //check database for sponsor times //made true once a setTimeout has been created to try again after a server error let recheckStarted = false; @@ -396,18 +408,6 @@ function sponsorsLookup(id, channelIDPromise) { updatePreviewBar(); } - if (channelIDPromise != null) { - if (channelIDPromise.isFulfilled) { - whitelistCheck(); - } else if (channelIDPromise.isRejected) { - //try again - wait(getChannelID).then(whitelistCheck).catch(); - } else { - //add it as a then statement - channelIDPromise.then(whitelistCheck); - } - } - sponsorLookupRetries = 0; } else if (xmlhttp.readyState == 4 && xmlhttp.status == 404) { sponsorDataFound = false; From a66c7c806395d64385e019fd278d43bf78fcda50 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 23 Nov 2019 18:05:42 -0500 Subject: [PATCH 4/7] Properly added submissions to sponsor times when done. --- content.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/content.js b/content.js index 2e55d804..86899f08 100644 --- a/content.js +++ b/content.js @@ -992,6 +992,8 @@ function sendSubmitMessage(){ let currentVideoID = sponsorVideoID; + let currentSponsorTimes = submitSponsorTimes; + chrome.runtime.sendMessage({ message: "submitTimes", videoID: currentVideoID @@ -1015,10 +1017,11 @@ function sendSubmitMessage(){ //clear the sponsor times let sponsorTimeKey = "sponsorTimes" + currentVideoID; - chrome.storage.sync.set({[sponsorTimeKey]: []}); + chrome.storage.sync.set({[sponsorTimeKey]: []}, () => void updatePreviewBar()); - //request the sponsors from the server again - sponsorsLookup(currentVideoID); + //add submissions to current sponsors list + sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting); + sponsorTimesSubmitting = []; } else { //show that the upload failed document.getElementById("submitButton").style.animation = "unset"; From 9cb3da4a7f46b5a42414cb55f51c58321fbf769c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 24 Nov 2019 00:05:35 -0500 Subject: [PATCH 5/7] Added a button to disable skipping. Also changed up popup look. Resolves https://github.com/ajayyy/SponsorBlock/issues/167 --- _locales/en/messages.json | 9 ++++++--- content.js | 23 ++++++++++++++++++++--- popup.css | 7 ++++++- popup.html | 16 ++++++++++------ popup.js | 37 +++++++++++++++++++++++++++++++++++-- 5 files changed, 77 insertions(+), 15 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index cbfed2b0..fa3a409d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -141,9 +141,6 @@ "removeFromWhitelist": { "message": "Remove Channel From Whitelist" }, - "whitelistDescription": { - "message": "Whitelist the channels who do sponsorships ethically to encourage good behavior, or maybe if they are just entertaining and funny. Or don't, that's your call." - }, "voteOnTime": { "message": "Vote On A Sponsor Time" }, @@ -265,5 +262,11 @@ }, "0": { "message": "Connection Timeout. Check your internet connection. If your internet is working, the server is probably overloaded or down." + }, + "disableSkipping": { + "message": "Disable SponsorBlock" + }, + "enableSkipping": { + "message": "Enable SponsorBlock" } } diff --git a/content.js b/content.js index 86899f08..920f0cd6 100644 --- a/content.js +++ b/content.js @@ -67,6 +67,15 @@ var sponsorTimesSubmitting = []; //this is used to close the popup on YouTube when the other popup opens var popupInitialised = false; +//should skips happen at all +var disableSkipping = false; +chrome.storage.sync.get(["disableSkipping"], function(result) { + let disableSkippingStorage = result.disableSkipping; + if (disableSkippingStorage != undefined) { + disableSkipping = disableSkippingStorage; + } +}); + //should view counts be tracked var trackViewCount = false; chrome.storage.sync.get(["trackViewCount"], function(result) { @@ -439,9 +448,11 @@ function sponsorsLookup(id, channelIDPromise) { }); //add the event to run on the videos "ontimeupdate" - v.ontimeupdate = function () { - sponsorCheck(); - }; + if (!disableSkipping) { + v.ontimeupdate = function () { + sponsorCheck(); + }; + } } function updatePreviewBar() { @@ -531,6 +542,12 @@ function whitelistCheck() { //video skipping function sponsorCheck() { + if (disableSkipping) { + // Make sure this isn't called again + v.ontimeupdate = null; + return; + } + let skipHappened = false; if (sponsorTimes != null) { diff --git a/popup.css b/popup.css index 182b2015..dccfd881 100644 --- a/popup.css +++ b/popup.css @@ -35,6 +35,10 @@ sub.popupElement { } /* end reset */ +#sponsorBlockPopupLogo { + vertical-align: text-bottom; +} + .popupElement { font-family: 'Source Sans Pro', sans-serif; @@ -43,12 +47,13 @@ sub.popupElement { h1.popupElement { margin-top: 0px; + margin-bottom: 10px; } .popupBody { font-size: 14px; background-color: #ffd9d9; - padding: 5px; + padding: 0px 5px; } .discreteLink.popupElement { diff --git a/popup.html b/popup.html index a2923eb0..503c7cef 100644 --- a/popup.html +++ b/popup.html @@ -8,9 +8,10 @@
- - -

__MSG_Name__

+

+ + __MSG_Name__ +

__MSG_Loading__

@@ -32,11 +33,14 @@
- - __MSG_whitelistDescription__ -
+ +
+ + +
+
diff --git a/popup.js b/popup.js index 337dd020..adebb80b 100644 --- a/popup.js +++ b/popup.js @@ -26,8 +26,12 @@ function runThePopup() { var SB = {}; ["sponsorStart", + // Top toggles "whitelistChannel", "unwhitelistChannel", + "disableSkipping", + "enableSkipping", + // More controls "clearTimes", "submitTimes", "showNoticeAgain", @@ -80,6 +84,8 @@ function runThePopup() { SB.sponsorStart.addEventListener("click", sendSponsorStartMessage); SB.whitelistChannel.addEventListener("click", whitelistChannel); SB.unwhitelistChannel.addEventListener("click", unwhitelistChannel); + SB.disableSkipping.addEventListener("click", () => toggleSkipping(true)); + SB.enableSkipping.addEventListener("click", () => toggleSkipping(false)); SB.clearTimes.addEventListener("click", clearTimes); SB.submitTimes.addEventListener("click", submitTimes); SB.showNoticeAgain.addEventListener("click", showNoticeAgain); @@ -134,7 +140,16 @@ function runThePopup() { } }); - //if the don't show notice again letiable is true, an option to + //show proper disable skipping button + chrome.storage.sync.get(["disableSkipping"], function(result) { + let disableSkipping = result.disableSkipping; + if (disableSkipping != undefined && disableSkipping) { + SB.disableSkipping.style.display = "none"; + SB.enableSkipping.style.display = "unset"; + } + }); + + //if the don't show notice again variable is true, an option to // disable should be available chrome.storage.sync.get(["dontShowNotice"], function(result) { let dontShowNotice = result.dontShowNotice; @@ -280,7 +295,7 @@ function runThePopup() { //remove loading text SB.mainControls.style.display = "unset" - SB.loadingIndicator.innerHTML = ""; + SB.loadingIndicator.style.display = "none"; if (request.found) { SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound"); @@ -1251,6 +1266,24 @@ function runThePopup() { }); } + /** + * Should skipping be disabled (visuals stay) + */ + function toggleSkipping(disabled) { + chrome.storage.sync.set({"disableSkipping": disabled}); + + let hiddenButton = SB.disableSkipping; + let shownButton = SB.enableSkipping; + + if (!disabled) { + hiddenButton = SB.enableSkipping; + shownButton = SB.disableSkipping; + } + + shownButton.style.display = "unset"; + hiddenButton.style.display = "none"; + } + function setKeybind(startSponsorKeybind) { document.getElementById("keybindButtons").style.display = "none"; From 600f9e4b850c56bfdaa79cc119e17090bec96947 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 24 Nov 2019 00:48:35 -0500 Subject: [PATCH 6/7] Changed order of popup. Also fixed discord link. Resolves https://github.com/ajayyy/SponsorBlock/issues/156. --- _locales/en/messages.json | 4 ++ popup.html | 122 ++++++++++++++++++-------------------- popup.js | 8 +-- 3 files changed, 67 insertions(+), 67 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index fa3a409d..26582468 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -268,5 +268,9 @@ }, "enableSkipping": { "message": "Enable SponsorBlock" + }, + "yourWork": { + "message": "Your Work", + "description": "Used to describe the section that will show you the statistics from your submissions." } } diff --git a/popup.html b/popup.html index 503c7cef..5b5a2948 100644 --- a/popup.html +++ b/popup.html @@ -15,21 +15,74 @@

__MSG_Loading__

- + -

__MSG_recordTimes__

+

__MSG_yourWork__

-

- __MSG_recordTimesDescription__ -

- -
- -
- - __MSG_popupHint__ - - -
-
-

@@ -134,35 +147,18 @@
- -
diff --git a/popup.js b/popup.js index adebb80b..30c928af 100644 --- a/popup.js +++ b/popup.js @@ -126,15 +126,15 @@ function runThePopup() { if (hideDiscordLink == undefined || !hideDiscordLink) { chrome.storage.sync.get(["hideDiscordLaunches"], function(result) { let hideDiscordLaunches = result.hideDiscordLaunches; - //only if less than 5 launches + //only if less than 10 launches if (hideDiscordLaunches == undefined || hideDiscordLaunches < 10) { SB.discordButtonContainer.style.display = null; if (hideDiscordLaunches == undefined) { - hideDiscordButton = 1; + hideDiscordLaunches = 1; } - chrome.storage.sync.set({"hideDiscordLaunches": hideDiscordButton + 1}); + chrome.storage.sync.set({"hideDiscordLaunches": hideDiscordLaunches + 1}); } }); } @@ -1150,7 +1150,7 @@ function runThePopup() { } function hideDiscordButton() { - chrome.storage.sync.set({"hideDiscordLink": false}); + chrome.storage.sync.set({"hideDiscordLink": true}); SB.discordButtonContainer.style.display = "none"; } From 468e33eff7769a370762fcd1bc13a27254fa032a Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 24 Nov 2019 00:53:51 -0500 Subject: [PATCH 7/7] Update version number. --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6741f50e..c8d06d88 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.1.9.4", + "version": "1.1.9.5", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [