mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Added a button to disable skipping. Also changed up popup look.
Resolves https://github.com/ajayyy/SponsorBlock/issues/167
This commit is contained in:
parent
a66c7c8063
commit
9cb3da4a7f
5 changed files with 77 additions and 15 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
23
content.js
23
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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
16
popup.html
16
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>
|
||||
|
|
37
popup.js
37
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";
|
||||
|
||||
|
|
Loading…
Reference in a new issue