Added a button to disable skipping. Also changed up popup look.

Resolves https://github.com/ajayyy/SponsorBlock/issues/167
This commit is contained in:
Ajay Ramachandran
2019-11-24 00:05:35 -05:00
parent a66c7c8063
commit 9cb3da4a7f
5 changed files with 77 additions and 15 deletions

View File

@@ -141,9 +141,6 @@
"removeFromWhitelist": { "removeFromWhitelist": {
"message": "Remove Channel From Whitelist" "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": { "voteOnTime": {
"message": "Vote On A Sponsor Time" "message": "Vote On A Sponsor Time"
}, },
@@ -265,5 +262,11 @@
}, },
"0": { "0": {
"message": "Connection Timeout. Check your internet connection. If your internet is working, the server is probably overloaded or down." "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"
} }
} }

View File

@@ -67,6 +67,15 @@ var sponsorTimesSubmitting = [];
//this is used to close the popup on YouTube when the other popup opens //this is used to close the popup on YouTube when the other popup opens
var popupInitialised = false; 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 //should view counts be tracked
var trackViewCount = false; var trackViewCount = false;
chrome.storage.sync.get(["trackViewCount"], function(result) { chrome.storage.sync.get(["trackViewCount"], function(result) {
@@ -439,9 +448,11 @@ function sponsorsLookup(id, channelIDPromise) {
}); });
//add the event to run on the videos "ontimeupdate" //add the event to run on the videos "ontimeupdate"
if (!disableSkipping) {
v.ontimeupdate = function () { v.ontimeupdate = function () {
sponsorCheck(); sponsorCheck();
}; };
}
} }
function updatePreviewBar() { function updatePreviewBar() {
@@ -531,6 +542,12 @@ function whitelistCheck() {
//video skipping //video skipping
function sponsorCheck() { function sponsorCheck() {
if (disableSkipping) {
// Make sure this isn't called again
v.ontimeupdate = null;
return;
}
let skipHappened = false; let skipHappened = false;
if (sponsorTimes != null) { if (sponsorTimes != null) {

View File

@@ -35,6 +35,10 @@ sub.popupElement {
} }
/* end reset */ /* end reset */
#sponsorBlockPopupLogo {
vertical-align: text-bottom;
}
.popupElement { .popupElement {
font-family: 'Source Sans Pro', sans-serif; font-family: 'Source Sans Pro', sans-serif;
@@ -43,12 +47,13 @@ sub.popupElement {
h1.popupElement { h1.popupElement {
margin-top: 0px; margin-top: 0px;
margin-bottom: 10px;
} }
.popupBody { .popupBody {
font-size: 14px; font-size: 14px;
background-color: #ffd9d9; background-color: #ffd9d9;
padding: 5px; padding: 0px 5px;
} }
.discreteLink.popupElement { .discreteLink.popupElement {

View File

@@ -8,9 +8,10 @@
<body class="popupBody"> <body class="popupBody">
<center> <center>
<div id="app" class="popupBody"> <div id="app" class="popupBody">
<img src="icons/LogoSponsorBlocker256px.png" height="64px" id="sponsorBlockPopupLogo"/> <h1 class="popupElement">
<img src="icons/IconSponsorBlocker256px.png" height="32px" id="sponsorBlockPopupLogo"/>
<h1 class="popupElement">__MSG_Name__</h1> __MSG_Name__
</h1>
<!-- Loading text --> <!-- Loading text -->
<p id="loadingIndicator" class="popupElement">__MSG_Loading__</p> <p id="loadingIndicator" class="popupElement">__MSG_Loading__</p>
@@ -32,11 +33,14 @@
<button id="whitelistChannel" class="whitelistButton popupElement">__MSG_whitelistChannel__</button> <button id="whitelistChannel" class="whitelistButton popupElement">__MSG_whitelistChannel__</button>
<button id="unwhitelistChannel" class="whitelistButton popupElement" style="display: none">__MSG_removeFromWhitelist__</button> <button id="unwhitelistChannel" class="whitelistButton popupElement" style="display: none">__MSG_removeFromWhitelist__</button>
</div> </div>
<sub class="popupElement">
__MSG_whitelistDescription__
</sub>
<br/> <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/> <br/>
<button id="reportAnIssue" class="dangerButton popupElement">__MSG_voteOnTime__</button> <button id="reportAnIssue" class="dangerButton popupElement">__MSG_voteOnTime__</button>

View File

@@ -26,8 +26,12 @@ function runThePopup() {
var SB = {}; var SB = {};
["sponsorStart", ["sponsorStart",
// Top toggles
"whitelistChannel", "whitelistChannel",
"unwhitelistChannel", "unwhitelistChannel",
"disableSkipping",
"enableSkipping",
// More controls
"clearTimes", "clearTimes",
"submitTimes", "submitTimes",
"showNoticeAgain", "showNoticeAgain",
@@ -80,6 +84,8 @@ function runThePopup() {
SB.sponsorStart.addEventListener("click", sendSponsorStartMessage); SB.sponsorStart.addEventListener("click", sendSponsorStartMessage);
SB.whitelistChannel.addEventListener("click", whitelistChannel); SB.whitelistChannel.addEventListener("click", whitelistChannel);
SB.unwhitelistChannel.addEventListener("click", unwhitelistChannel); SB.unwhitelistChannel.addEventListener("click", unwhitelistChannel);
SB.disableSkipping.addEventListener("click", () => toggleSkipping(true));
SB.enableSkipping.addEventListener("click", () => toggleSkipping(false));
SB.clearTimes.addEventListener("click", clearTimes); SB.clearTimes.addEventListener("click", clearTimes);
SB.submitTimes.addEventListener("click", submitTimes); SB.submitTimes.addEventListener("click", submitTimes);
SB.showNoticeAgain.addEventListener("click", showNoticeAgain); 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 // disable should be available
chrome.storage.sync.get(["dontShowNotice"], function(result) { chrome.storage.sync.get(["dontShowNotice"], function(result) {
let dontShowNotice = result.dontShowNotice; let dontShowNotice = result.dontShowNotice;
@@ -280,7 +295,7 @@ function runThePopup() {
//remove loading text //remove loading text
SB.mainControls.style.display = "unset" SB.mainControls.style.display = "unset"
SB.loadingIndicator.innerHTML = ""; SB.loadingIndicator.style.display = "none";
if (request.found) { if (request.found) {
SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound"); 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) { function setKeybind(startSponsorKeybind) {
document.getElementById("keybindButtons").style.display = "none"; document.getElementById("keybindButtons").style.display = "none";