aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-11-24 00:05:35 -0500
committerAjay Ramachandran <[email protected]>2019-11-24 00:05:35 -0500
commit9cb3da4a7f46b5a42414cb55f51c58321fbf769c (patch)
tree6068f30b0cef4ec8da62d4df154286016b7b0f66
parenta66c7c806395d64385e019fd278d43bf78fcda50 (diff)
downloadSponsorBlock-9cb3da4a7f46b5a42414cb55f51c58321fbf769c.tar.gz
SponsorBlock-9cb3da4a7f46b5a42414cb55f51c58321fbf769c.zip
Added a button to disable skipping. Also changed up popup look.
Resolves https://github.com/ajayyy/SponsorBlock/issues/167
-rw-r--r--_locales/en/messages.json9
-rw-r--r--content.js23
-rw-r--r--popup.css7
-rw-r--r--popup.html16
-rw-r--r--popup.js37
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 @@
<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>
@@ -32,11 +33,14 @@
<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>
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";