diff options
author | Ajay Ramachandran <[email protected]> | 2019-11-24 00:55:04 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-24 00:55:04 -0500 |
commit | f35d34a807896d8fa4ca98b4ba4d7a3bf6c5246f (patch) | |
tree | 03829d552b95c0928287278e2006f7167346e58f | |
parent | 2a025b79779d02f3a4dd0fa7d5d6db01b0a385c4 (diff) | |
parent | 468e33eff7769a370762fcd1bc13a27254fa032a (diff) | |
download | SponsorBlock-f35d34a807896d8fa4ca98b4ba4d7a3bf6c5246f.tar.gz SponsorBlock-f35d34a807896d8fa4ca98b4ba4d7a3bf6c5246f.zip |
Merge pull request #172 from ajayyy/experimental-ajay11.9.5
Small features and bug fixes
-rw-r--r-- | _locales/en/messages.json | 17 | ||||
-rw-r--r-- | _locales/fr/messages.json | 4 | ||||
-rw-r--r-- | _locales/it/messages.json | 4 | ||||
-rw-r--r-- | _locales/pt_BR/messages.json | 4 | ||||
-rw-r--r-- | _locales/pt_pt/messages.json | 4 | ||||
-rw-r--r-- | content.js | 73 | ||||
-rw-r--r-- | manifest.json | 2 | ||||
-rw-r--r-- | popup.css | 7 | ||||
-rw-r--r-- | popup.html | 138 | ||||
-rw-r--r-- | popup.js | 45 |
10 files changed, 173 insertions, 125 deletions
diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 42256bb1..26582468 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" }, @@ -193,10 +190,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." @@ -265,5 +262,15 @@ }, "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" + }, + "yourWork": { + "message": "Your Work", + "description": "Used to describe the section that will show you the statistics from your submissions." } } 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." @@ -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) { @@ -378,6 +387,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 +417,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; @@ -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() { @@ -525,29 +536,18 @@ 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}); - } } }); } //video skipping function sponsorCheck() { + if (disableSkipping) { + // Make sure this isn't called again + v.ontimeupdate = null; + return; + } + let skipHappened = false; if (sponsorTimes != null) { @@ -1009,6 +1009,8 @@ function sendSubmitMessage(){ let currentVideoID = sponsorVideoID; + let currentSponsorTimes = submitSponsorTimes; + chrome.runtime.sendMessage({ message: "submitTimes", videoID: currentVideoID @@ -1032,10 +1034,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"; 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": [ @@ -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 { @@ -8,35 +8,92 @@ <body class="popupBody"> <center> <div id="app" class="popupBody"> - <img src="icons/LogoSponsorBlocker256px.png" height="64px" id="sponsorBlockPopupLogo"/> - - <h1 class="popupElement">__MSG_Name__</h1> + <h1 class="popupElement"> + <img src="icons/IconSponsorBlocker256px.png" height="32px" id="sponsorBlockPopupLogo"/> + __MSG_Name__ + </h1> <!-- Loading text --> <p id="loadingIndicator" class="popupElement">__MSG_Loading__</p> - + <!-- Hidden until loading complete --> <div id="mainControls" class="main popupElement" style="display: none"> <!-- If the video was found in the database --> <div id="videoFound"> - + </div> <div id="downloadedSponsorMessageTimes" class="popupElement"> + + </div> + <p class="popupElement"> + __MSG_recordTimesDescription__ + </p> + + <div> + <button id="sponsorStart" class="greenButton popupElement">__MSG_sponsorStart__</button> + </div> + + <sub class="popupElement">__MSG_popupHint__</sub> + + <div id="submissionSection" class="popupElement" style="display: none"> + <h3 class="popupElement">__MSG_lastTimes__</h3> + <b> + <div id="sponsorMessageTimes" class="popupElement"> + + </div> + </b> + + <br/> + + <button id="clearTimes" class="smallButton popupElement">__MSG_clearTimesButton__</button> + + <div id="submitTimesContainer" class="popupElement" style="display: none"> + + <br/> + <br/> + + <button id="submitTimes" class="smallButton popupElement">__MSG_submitTimesButton__</button> + + <div id="submitTimesInfoMessageContainer" class="popupElement" style="display: none"> + <h3 id="submitTimesInfoMessage" class="popupElement"> + + </h3> + </div> + + </div> + + </div> + + <div id="discordButtonContainer" class="popupElement" style="display: none"> + <br/> + + <a href="https://discord.gg/QnmVMpU" class="popupElement" target="_blank"><img src="https://www.logolynx.com/images/logolynx/1b/1bcc0f0aefe71b2c8ce66ffe8645d365.png" height="32px"/></a> + + <br/> + + __MSG_discordAdvert__ + + <br/> + + <span id="hideDiscordButton" class="smallLink popupElement">__MSG_hideThis__</span> </div> - - <br/> <div> + <br/> + <button id="whitelistChannel" class="whitelistButton popupElement">__MSG_whitelistChannel__</button> <button id="unwhitelistChannel" class="whitelistButton popupElement" style="display: none">__MSG_removeFromWhitelist__</button> </div> - <sub class="popupElement"> - __MSG_whitelistDescription__ - </sub> <br/> + + <div> + <button id="disableSkipping" class="greenButton popupElement">__MSG_disableSkipping__</button> + <button id="enableSkipping" class="whitelistButton popupElement" style="display: none">__MSG_enableSkipping__</button> + </div> + <br/> <button id="reportAnIssue" class="dangerButton popupElement">__MSG_voteOnTime__</button> @@ -51,7 +108,7 @@ </div> - <h2 class="recordingSubtitle popupElement">__MSG_recordTimes__</h2> + <h2 class="recordingSubtitle popupElement">__MSG_yourWork__</h2> <p class="popupElement"> <span id=sponsorTimesContributionsContainer class="popupElement" style="display: none"> @@ -80,47 +137,7 @@ </div> </p> - <p class="popupElement"> - __MSG_recordTimesDescription__ - </p> - - <div> - <button id="sponsorStart" class="greenButton popupElement">__MSG_sponsorStart__</button> - </div> - - <sub class="popupElement">__MSG_popupHint__</sub> - - <div id="submissionSection" class="popupElement" style="display: none"> - <h3 class="popupElement">__MSG_lastTimes__</h3> - <b> - <div id="sponsorMessageTimes" class="popupElement"> - - </div> - </b> - - <br/> - - <button id="clearTimes" class="smallButton popupElement">__MSG_clearTimesButton__</button> - - <br/> - <br/> - - <div id="submitTimesContainer" class="popupElement" style="display: none"> - <button id="submitTimes" class="smallButton popupElement">__MSG_submitTimesButton__</button> - - <div id="submitTimesInfoMessageContainer" class="popupElement" style="display: none"> - <h3 id="submitTimesInfoMessage" class="popupElement"> - - </h3> - </div> - - </div> - - </div> - <div id="setUsernameContainer" class="popupElement"> - <br/> - <br/> <button id="setUsernameButton" class="warningButton popupElement">__MSG_setUsername__</button> <br/> @@ -130,35 +147,18 @@ </div> <div id="setUsername" class="popupElement" style="display: none"> - <br/> - <h3>__MSG_setUsername__</h3> <div id="setUsernameStatusContainer" style="display: none"> <h2 id="setUsernameStatus"></h2> </div> - <input id="usernameInput" hint="Username"></input> <br/> <br/> - <button id="submitUsername" class="warningButton popupElement">Submit Username</button> - </div> - - <div id="discordButtonContainer" class="popupElement" style="display: none"> - <br/> - - <a href="https://discord.gg/QnmVMpU" class="popupElement" target="_blank"><img src="https://www.logolynx.com/images/logolynx/1b/1bcc0f0aefe71b2c8ce66ffe8645d365.png" height="32px"/></a> - - <br/> - - __MSG_discordAdvert__ - - <br/> - - <span id="hideDiscordButton" class="smallLink popupElement">__MSG_hideThis__</span> + <button id="submitUsername" class="warningButton popupElement">__MSG_setUsername__</button> </div> <div id="optionsButtonContainer" class="popupElement"> @@ -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); @@ -120,21 +126,30 @@ 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}); } }); } }); - //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"); @@ -1135,7 +1150,7 @@ function runThePopup() { } function hideDiscordButton() { - chrome.storage.sync.set({"hideDiscordLink": false}); + chrome.storage.sync.set({"hideDiscordLink": true}); SB.discordButtonContainer.style.display = "none"; } @@ -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"; |