Merge pull request #172 from ajayyy/experimental-ajay

Small features and bug fixes
This commit is contained in:
Ajay Ramachandran 2019-11-24 00:55:04 -05:00 committed by GitHub
commit f35d34a807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 173 additions and 125 deletions

View file

@ -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."
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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": [

View file

@ -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 {

View file

@ -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>
<br/>
<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>
<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">

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