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

@@ -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";