Compare commits

...

21 Commits

Author SHA1 Message Date
Ajay Ramachandran
62d4b365c2 Merge pull request #173 from ajayyy/experimental-ajay
Made the popup work on non YouTube tabs
2019-11-24 01:16:56 -05:00
Ajay Ramachandran
524df6389a Update version number. 2019-11-24 01:14:55 -05:00
Ajay Ramachandran
24292e771b Made the popup work on non YouTube tabs. 2019-11-24 01:13:52 -05:00
Ajay Ramachandran
f35d34a807 Merge pull request #172 from ajayyy/experimental-ajay
Small features and bug fixes
2019-11-24 00:55:04 -05:00
Ajay Ramachandran
468e33eff7 Update version number. 2019-11-24 00:53:51 -05:00
Ajay Ramachandran
600f9e4b85 Changed order of popup. Also fixed discord link.
Resolves https://github.com/ajayyy/SponsorBlock/issues/156.
2019-11-24 00:48:35 -05:00
Ajay Ramachandran
9cb3da4a7f Added a button to disable skipping. Also changed up popup look.
Resolves https://github.com/ajayyy/SponsorBlock/issues/167
2019-11-24 00:05:35 -05:00
Ajay Ramachandran
a66c7c8063 Properly added submissions to sponsor times when done. 2019-11-23 18:05:42 -05:00
Ajay Ramachandran
0a84dbd3a5 Improved speed of whitelist check. 2019-11-23 17:53:04 -05:00
Ajay Ramachandran
2fa412e574 Removed deprecated code to fix whitelist array. 2019-11-23 17:44:22 -05:00
Ajay Ramachandran
f240416886 Fixed reversed strings.
Resolves https://github.com/ajayyy/SponsorBlock/issues/170.
2019-11-23 14:35:33 -05:00
Ajay Ramachandran
2a025b7977 Fixed formatting in readme 2019-11-23 13:33:55 -05:00
Ajay Ramachandran
f44d2b67e5 Added link to MPV port 2019-11-23 13:33:22 -05:00
Ajay Ramachandran
6b15ebac99 Added link in readme 2019-11-23 12:54:34 -05:00
Ajay Ramachandran
ff41251f17 Merge pull request #171 from ajayyy/experimental-ajay
Fixed error message, prevented double counting contributions and delayed userID generation
2019-11-23 12:49:19 -05:00
Ajay Ramachandran
c7c1cb79a8 Increased version number. 2019-11-23 12:48:10 -05:00
Ajay Ramachandran
fc155ccdfa Prevented contributions from counting twice. 2019-11-23 12:47:00 -05:00
Ajay Ramachandran
dfad1a5636 Added delayed startup after install. 2019-11-23 12:44:38 -05:00
Ajay Ramachandran
6790952f86 Fixed error messages not working. Added message for error 503 and 0. 2019-11-23 12:26:24 -05:00
Ajay Ramachandran
1a28f714a1 Update README.md 2019-11-17 21:32:31 -05:00
Ajay Ramachandran
55a55fefba Update README.md 2019-11-17 21:32:01 -05:00
12 changed files with 310 additions and 232 deletions

View File

@@ -1,5 +1,5 @@
<p align="center"> <p align="center">
<img src="icons/LogoSponsorBlocker256px.png" alt="Logo"></img> <a href="https://sponsor.ajay.app"><img src="icons/LogoSponsorBlocker256px.png" alt="Logo"></img></a>
<br/> <br/>
<sub>Logo by <a href="https://github.com/munadikieh">@munadikieh</a></sub> <sub>Logo by <a href="https://github.com/munadikieh">@munadikieh</a></sub>
@@ -8,12 +8,18 @@
<h1 align="center">SponsorBlock</h1> <h1 align="center">SponsorBlock</h1>
<p align="center"> <p align="center">
<b>Download:</b>
<a href="https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone">Chrome/Chromium</a> | <a href="https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone">Chrome/Chromium</a> |
<a href="https://addons.mozilla.org/addon/sponsorblock/?src=external-github">Firefox</a> | <a href="https://addons.mozilla.org/addon/sponsorblock/?src=external-github">Firefox</a> |
<a href="https://sponsor.ajay.app">Website</a> | <a href="https://sponsor.ajay.app">Website</a> |
<a href="https://sponsor.ajay.app/stats">Stats</a> <a href="https://sponsor.ajay.app/stats">Stats</a>
</p> </p>
<p align="center">
<b>Unofficial Ports:</b>
<a href="https://github.com/ajayyy/SponsorBlock/wiki/Unofficial-Ports#mpv-media-player">MPV</a>
</p>
<p align="center"> <p align="center">
<a href="https://addons.mozilla.org/addon/sponsorblock/?src=external-github"><img src="https://img.shields.io/amo/users/sponsorblock?label=Firefox%20Users" alt="Badge"></img></a> <a href="https://addons.mozilla.org/addon/sponsorblock/?src=external-github"><img src="https://img.shields.io/amo/users/sponsorblock?label=Firefox%20Users" alt="Badge"></img></a>
<a href="https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone"><img src="https://img.shields.io/chrome-web-store/users/mnjggcdmjocbbbhaepdhchncahnbgone?label=Chome%20Users" alt="Badge"></img></a> <a href="https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone"><img src="https://img.shields.io/chrome-web-store/users/mnjggcdmjocbbbhaepdhchncahnbgone?label=Chome%20Users" alt="Badge"></img></a>
@@ -48,6 +54,8 @@ You can load this project as an unpacked extension. Make sure to rename the `con
The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) is used to grab the time the video was published. The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) is used to grab the time the video was published.
Original code from [YTSponsorSkip](https://github.com/OfficialNoob/YTSponsorSkip), but not much of the code is left.
Some icons made by <a href="https://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> and are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a> Some icons made by <a href="https://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> and are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
Some icons made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a> Some icons made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>

View File

@@ -100,7 +100,7 @@
"message": "Sponsorship Ends Now" "message": "Sponsorship Ends Now"
}, },
"noVideoID": { "noVideoID": {
"message": "This probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again.\n\nYou must refresh your YouTube tab after installing or updating (even auto-update) the extension." "message": "No YouTube video found at this tab. If you know this is a YouTube tab, close this popup and open it again. If that does not work, try reloading the tab."
}, },
"success": { "success": {
"message": "Success!" "message": "Success!"
@@ -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"
}, },
@@ -193,10 +190,10 @@
"message": "Options" "message": "Options"
}, },
"showButtons": { "showButtons": {
"message": "Hide Buttons On YouTube Player" "message": "Show Buttons On YouTube Player"
}, },
"hideButtons": { "hideButtons": {
"message": "Show Buttons On YouTube Player" "message": "Hide Buttons On YouTube Player"
}, },
"hideButtonsDescription": { "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." "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."
@@ -262,5 +259,18 @@
}, },
"keybindDescriptionComplete": { "keybindDescriptionComplete": {
"message": "The keybind has been set to: " "message": "The keybind has been set to: "
},
"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" "message": "Options"
}, },
"showButtons": { "showButtons": {
"message": "Cacher les boutons sur le lecteur YouTube" "message": "Montrer les boutons sur le lecteur YouTube"
}, },
"hideButtons": { "hideButtons": {
"message": "Montrer les boutons sur le lecteur YouTube" "message": "Cacher les boutons sur le lecteur YouTube"
}, },
"hideButtonsDescription": { "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." "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" "message": "Opzioni"
}, },
"showButtons": { "showButtons": {
"message": "Nascondi i Pulsanti nel Lettore di YouTube" "message": "Mostra i Pulsanti nel Lettore di YouTube"
}, },
"hideButtons": { "hideButtons": {
"message": "Mostra i Pulsanti nel Lettore di YouTube" "message": "Nascondi i Pulsanti nel Lettore di YouTube"
}, },
"hideButtonsDescription": { "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." "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" "message": "Opções"
}, },
"showButtons": { "showButtons": {
"message": "Esconder botões no player do Youtube" "message": "Mostrar botões no player do Youtube"
}, },
"hideButtons": { "hideButtons": {
"message": "Mostrar botões no player do Youtube" "message": "Esconder botões no player do Youtube"
}, },
"hideButtonsDescription": { "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." "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" "message": "Opções"
}, },
"showButtons": { "showButtons": {
"message": "Esconder botões no player do Youtube" "message": "Mostrar botões no player do Youtube"
}, },
"hideButtons": { "hideButtons": {
"message": "Mostrar botões no player do Youtube" "message": "Esconder botões no player do Youtube"
}, },
"hideButtonsDescription": { "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." "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

@@ -42,13 +42,14 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//add help page on install //add help page on install
chrome.runtime.onInstalled.addListener(function (object) { chrome.runtime.onInstalled.addListener(function (object) {
chrome.storage.sync.get(["userID", "shownInstallPage"], function(result) { setTimeout(function() {
chrome.storage.sync.get(["userID"], function(result) {
const userID = result.userID; const userID = result.userID;
// If there is no userID, then it is the first install. // If there is no userID, then it is the first install.
if (!userID){ if (!userID){
//open up the install page //open up the install page
chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))}); chrome.tabs.create({url: chrome.extension.getURL("/help/index_en.html")});
//generate a userID //generate a userID
const newUserID = generateUserID(); const newUserID = generateUserID();
@@ -58,6 +59,7 @@ chrome.runtime.onInstalled.addListener(function (object) {
}); });
} }
}); });
}, 1500);
}); });
//gets the sponsor times from memory //gets the sponsor times from memory
@@ -157,6 +159,9 @@ function submitTimes(videoID, callback) {
//submit these times //submit these times
for (let i = 0; i < sponsorTimes.length; i++) { for (let i = 0; i < sponsorTimes.length; i++) {
//to prevent it from happeneing twice
let increasedContributionAmount = false;
//submit the sponsorTime //submit the sponsorTime
sendRequestToServer("GET", "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1] sendRequestToServer("GET", "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1]
+ "&userID=" + userID, function(xmlhttp, error) { + "&userID=" + userID, function(xmlhttp, error) {
@@ -175,7 +180,11 @@ function submitTimes(videoID, callback) {
} }
//save the amount contributed //save the amount contributed
if (!increasedContributionAmount) {
increasedContributionAmount = true;
chrome.storage.sync.set({"sponsorTimesContributed": currentContributionAmount + sponsorTimes.length}); chrome.storage.sync.set({"sponsorTimesContributed": currentContributionAmount + sponsorTimes.length});
}
}); });
} }
} else if (error) { } else if (error) {

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) {
@@ -378,6 +387,18 @@ function sponsorsLookup(id, channelIDPromise) {
v.addEventListener('durationchange', updatePreviewBar); 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 //check database for sponsor times
//made true once a setTimeout has been created to try again after a server error //made true once a setTimeout has been created to try again after a server error
let recheckStarted = false; let recheckStarted = false;
@@ -396,18 +417,6 @@ function sponsorsLookup(id, channelIDPromise) {
updatePreviewBar(); 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; sponsorLookupRetries = 0;
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 404) { } else if (xmlhttp.readyState == 4 && xmlhttp.status == 404) {
sponsorDataFound = false; sponsorDataFound = false;
@@ -439,10 +448,12 @@ 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() {
let localSponsorTimes = sponsorTimes; let localSponsorTimes = sponsorTimes;
@@ -525,29 +536,18 @@ function whitelistCheck() {
UUIDs = []; UUIDs = [];
channelWhitelisted = true; 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 //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) {
@@ -1009,6 +1009,8 @@ function sendSubmitMessage(){
let currentVideoID = sponsorVideoID; let currentVideoID = sponsorVideoID;
let currentSponsorTimes = submitSponsorTimes;
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
message: "submitTimes", message: "submitTimes",
videoID: currentVideoID videoID: currentVideoID
@@ -1032,17 +1034,21 @@ function sendSubmitMessage(){
//clear the sponsor times //clear the sponsor times
let sponsorTimeKey = "sponsorTimes" + currentVideoID; let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.sync.set({[sponsorTimeKey]: []}); chrome.storage.sync.set({[sponsorTimeKey]: []}, () => void updatePreviewBar());
//request the sponsors from the server again //add submissions to current sponsors list
sponsorsLookup(currentVideoID); sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
sponsorTimesSubmitting = [];
} else { } else {
//show that the upload failed //show that the upload failed
document.getElementById("submitButton").style.animation = "unset"; document.getElementById("submitButton").style.animation = "unset";
document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png"); document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
if([400,429,409,502].includes(response.statusCode)) { if([400, 429, 409, 502, 0].includes(response.statusCode)) {
alert(chrome.i18n.getMessage(response.statusCode)); //treat them the same
if (response.statusCode == 503) response.statusCode = 502;
alert(chrome.i18n.getMessage(response.statusCode + ""));
} else { } else {
alert(chrome.i18n.getMessage("connectionError") + response.statusCode); alert(chrome.i18n.getMessage("connectionError") + response.statusCode);
} }

View File

@@ -1,7 +1,7 @@
{ {
"name": "__MSG_fullName__", "name": "__MSG_fullName__",
"short_name": "__MSG_Name__", "short_name": "__MSG_Name__",
"version": "1.1.9.3", "version": "1.1.9.6",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_Description__", "description": "__MSG_Description__",
"content_scripts": [ "content_scripts": [

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,12 +8,13 @@
<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_noVideoID__</p>
<!-- Hidden until loading complete --> <!-- Hidden until loading complete -->
<div id="mainControls" class="main popupElement" style="display: none"> <div id="mainControls" class="main popupElement" style="display: none">
@@ -26,17 +27,66 @@
</div> </div>
<br/> <p class="popupElement">
__MSG_recordTimesDescription__
</p>
<div> <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>
<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="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/> <br/>
<button id="reportAnIssue" class="dangerButton popupElement">__MSG_voteOnTime__</button> <button id="reportAnIssue" class="dangerButton popupElement">__MSG_voteOnTime__</button>
@@ -51,7 +101,17 @@
</div> </div>
<h2 class="recordingSubtitle popupElement">__MSG_recordTimes__</h2> <br/>
<br/>
</div>
<div>
<button id="disableSkipping" class="greenButton popupElement">__MSG_disableSkipping__</button>
<button id="enableSkipping" class="whitelistButton popupElement" style="display: none">__MSG_enableSkipping__</button>
</div>
<h2 class="recordingSubtitle popupElement">__MSG_yourWork__</h2>
<p class="popupElement"> <p class="popupElement">
<span id=sponsorTimesContributionsContainer class="popupElement" style="display: none"> <span id=sponsorTimesContributionsContainer class="popupElement" style="display: none">
@@ -80,47 +140,7 @@
</div> </div>
</p> </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"> <div id="setUsernameContainer" class="popupElement">
<br/>
<br/>
<button id="setUsernameButton" class="warningButton popupElement">__MSG_setUsername__</button> <button id="setUsernameButton" class="warningButton popupElement">__MSG_setUsername__</button>
<br/> <br/>
@@ -130,35 +150,18 @@
</div> </div>
<div id="setUsername" class="popupElement" style="display: none"> <div id="setUsername" class="popupElement" style="display: none">
<br/>
<h3>__MSG_setUsername__</h3> <h3>__MSG_setUsername__</h3>
<div id="setUsernameStatusContainer" style="display: none"> <div id="setUsernameStatusContainer" style="display: none">
<h2 id="setUsernameStatus"></h2> <h2 id="setUsernameStatus"></h2>
</div> </div>
<input id="usernameInput" hint="Username"></input> <input id="usernameInput" hint="Username"></input>
<br/> <br/>
<br/> <br/>
<button id="submitUsername" class="warningButton popupElement">Submit Username</button> <button id="submitUsername" class="warningButton popupElement">__MSG_setUsername__</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>
</div> </div>
<div id="optionsButtonContainer" class="popupElement"> <div id="optionsButtonContainer" class="popupElement">
@@ -229,7 +232,6 @@
<button id="showNoticeAgain" style="display: none" class="dangerButton popupElement">__MSG_showNotice__</button> <button id="showNoticeAgain" style="display: none" class="dangerButton popupElement">__MSG_showNotice__</button>
</div> </div>
</div> </div>
</div>
</center> </center>
</body> </body>

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);
@@ -120,21 +126,30 @@ function runThePopup() {
if (hideDiscordLink == undefined || !hideDiscordLink) { if (hideDiscordLink == undefined || !hideDiscordLink) {
chrome.storage.sync.get(["hideDiscordLaunches"], function(result) { chrome.storage.sync.get(["hideDiscordLaunches"], function(result) {
let hideDiscordLaunches = result.hideDiscordLaunches; let hideDiscordLaunches = result.hideDiscordLaunches;
//only if less than 5 launches //only if less than 10 launches
if (hideDiscordLaunches == undefined || hideDiscordLaunches < 10) { if (hideDiscordLaunches == undefined || hideDiscordLaunches < 10) {
SB.discordButtonContainer.style.display = null; SB.discordButtonContainer.style.display = null;
if (hideDiscordLaunches == undefined) { 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 // 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");
@@ -811,8 +826,11 @@ function runThePopup() {
} else { } else {
let errorMessage = ""; let errorMessage = "";
if([400,429,409,502].includes(response.statusCode)) { if([400, 429, 409, 502, 0].includes(response.statusCode)) {
errorMessage = chrome.i18n.getMessage(response.statusCode); //treat them the same
if (response.statusCode == 503) response.statusCode = 502;
errorMessage = chrome.i18n.getMessage(response.statusCode + "");
} else { } else {
errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode; errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode;
} }
@@ -1109,8 +1127,10 @@ function runThePopup() {
type: type, type: type,
UUID: UUID UUID: UUID
}, function(response) { }, function(response) {
console.log(response)
if (response != undefined) { if (response != undefined) {
//see if it was a success or failure //see if it was a success or failure
console.log(response)
if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) { if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
//success (treat rate limits as a success) //success (treat rate limits as a success)
addVoteMessage(chrome.i18n.getMessage("voted"), UUID) addVoteMessage(chrome.i18n.getMessage("voted"), UUID)
@@ -1130,7 +1150,7 @@ function runThePopup() {
} }
function hideDiscordButton() { function hideDiscordButton() {
chrome.storage.sync.set({"hideDiscordLink": false}); chrome.storage.sync.set({"hideDiscordLink": true});
SB.discordButtonContainer.style.display = "none"; SB.discordButtonContainer.style.display = "none";
} }
@@ -1246,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";