mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 14:37:23 +03:00
Merge branch 'experimental' of https://github.com/ajayyy/SponsorBlock into experimental-ajay
# Conflicts: # manifest.json
This commit is contained in:
112
_locales/en/messages.json
Normal file
112
_locales/en/messages.json
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
{
|
||||||
|
"Name": {
|
||||||
|
"message": "SponsorBlock",
|
||||||
|
"description": "Name of the extension."
|
||||||
|
},
|
||||||
|
"fullName": {
|
||||||
|
"message": "SponsorBlock for YouTube - Skip Sponsorships",
|
||||||
|
"description": "Name of the extension."
|
||||||
|
},
|
||||||
|
|
||||||
|
"Description": {
|
||||||
|
"message": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
||||||
|
"description": "Description of the extension."
|
||||||
|
},
|
||||||
|
"helpPage": {
|
||||||
|
"message": "index_en.html"
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"message": "Server said this request was invalid"
|
||||||
|
},
|
||||||
|
"429": {
|
||||||
|
"message": "You have submitted too many sponsor times for this one video, are you sure there are this many?"
|
||||||
|
},
|
||||||
|
"409": {
|
||||||
|
"message": "This has already been submitted before"
|
||||||
|
},
|
||||||
|
"502": {
|
||||||
|
"message": "It seems the server is down. Contact the dev to inform them."
|
||||||
|
},
|
||||||
|
"channelWhitelisted": {
|
||||||
|
"message": "Channel Whitelisted!"
|
||||||
|
},
|
||||||
|
"Sponsor": {
|
||||||
|
"message": "Sponsor"
|
||||||
|
},
|
||||||
|
"Sponsors": {
|
||||||
|
"message": "Sponsors"
|
||||||
|
},
|
||||||
|
"Segment": {
|
||||||
|
"message": "sponsor segment"
|
||||||
|
},
|
||||||
|
"Segments": {
|
||||||
|
"message": "sponsor segments"
|
||||||
|
},
|
||||||
|
"Dismiss": {
|
||||||
|
"message": "Dismiss"
|
||||||
|
},
|
||||||
|
"Loading": {
|
||||||
|
"message": "Loading..."
|
||||||
|
},
|
||||||
|
"Mins": {
|
||||||
|
"message": "Minutes"
|
||||||
|
},
|
||||||
|
"Secs": {
|
||||||
|
"message": "Seconds"
|
||||||
|
},
|
||||||
|
"Hide": {
|
||||||
|
"message": "Don't Show This Again"
|
||||||
|
},
|
||||||
|
"hitGoBack": {
|
||||||
|
"message": "Hit go back to get to where you came from."
|
||||||
|
},
|
||||||
|
"goBack": {
|
||||||
|
"message": "Go back"
|
||||||
|
},
|
||||||
|
"confirmMSG": {
|
||||||
|
"message": "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner."
|
||||||
|
},
|
||||||
|
"clearThis": {
|
||||||
|
"message": "Are you sure you want to clear this?\n\n"
|
||||||
|
},
|
||||||
|
"Unknown": {
|
||||||
|
"message": "There was an error submitting your sponsor times, please try again later."
|
||||||
|
},
|
||||||
|
|
||||||
|
"sponsorFound": {
|
||||||
|
"message": "This video's sponsors are in the database!"
|
||||||
|
},
|
||||||
|
"sponsor404": {
|
||||||
|
"message": "No sponsors found"
|
||||||
|
},
|
||||||
|
"sponsorStart": {
|
||||||
|
"message": "Sponsorship Starts Now"
|
||||||
|
},
|
||||||
|
"sponsorEND": {
|
||||||
|
"message": "Sponsorship Ends Now"
|
||||||
|
},
|
||||||
|
"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."
|
||||||
|
},
|
||||||
|
"Voted": {
|
||||||
|
"message": "Thanks for voting!"
|
||||||
|
},
|
||||||
|
"voteFAIL": {
|
||||||
|
"message": "You have already voted this way before."
|
||||||
|
},
|
||||||
|
"serverDown": {
|
||||||
|
"message": "It seems the sever is down. Contact the dev immediately."
|
||||||
|
},
|
||||||
|
"connectionError": {
|
||||||
|
"message": "A connection error has occured. Error code: "
|
||||||
|
},
|
||||||
|
"wantToSubmit": {
|
||||||
|
"message": "Do you want to submit the sponsor times for video id"
|
||||||
|
},
|
||||||
|
"leftTimes": {
|
||||||
|
"message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)."
|
||||||
|
},
|
||||||
|
"Popup": {
|
||||||
|
"message": "popup_en.html"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,7 +56,8 @@ chrome.runtime.onInstalled.addListener(function (object) {
|
|||||||
// TODO (shownInstallPage): remove this if statement, but leave contents
|
// TODO (shownInstallPage): remove this if statement, but leave contents
|
||||||
if (!shownInstallPage){
|
if (!shownInstallPage){
|
||||||
//open up the install page
|
//open up the install page
|
||||||
chrome.tabs.create({url: chrome.extension.getURL("/help/index.html")});
|
|
||||||
|
chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (shownInstallPage): delete if statement and contents
|
// TODO (shownInstallPage): delete if statement and contents
|
||||||
|
|||||||
39
content.js
39
content.js
@@ -521,7 +521,7 @@ function addPlayerControlsButton() {
|
|||||||
let startSponsorButton = document.createElement("button");
|
let startSponsorButton = document.createElement("button");
|
||||||
startSponsorButton.id = "startSponsorButton";
|
startSponsorButton.id = "startSponsorButton";
|
||||||
startSponsorButton.className = "ytp-button playerButton";
|
startSponsorButton.className = "ytp-button playerButton";
|
||||||
startSponsorButton.setAttribute("title", "Sponsor Starts Now");
|
startSponsorButton.setAttribute("title", chrome.i18n.getMessage("sponsorStart"));
|
||||||
startSponsorButton.addEventListener("click", startSponsorClicked);
|
startSponsorButton.addEventListener("click", startSponsorClicked);
|
||||||
|
|
||||||
let startSponsorImage = document.createElement("img");
|
let startSponsorImage = document.createElement("img");
|
||||||
@@ -613,7 +613,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
|||||||
if (showStartSponsor) {
|
if (showStartSponsor) {
|
||||||
showingStartSponsor = true;
|
showingStartSponsor = true;
|
||||||
document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
|
document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
|
||||||
document.getElementById("startSponsorButton").setAttribute("title", "Sponsor Starts Now");
|
document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("sponsorStart"));
|
||||||
|
|
||||||
if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !hideInfoButtonPlayerControls) {
|
if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !hideInfoButtonPlayerControls) {
|
||||||
document.getElementById("submitButton").style.display = "unset";
|
document.getElementById("submitButton").style.display = "unset";
|
||||||
@@ -624,7 +624,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
|||||||
} else {
|
} else {
|
||||||
showingStartSponsor = false;
|
showingStartSponsor = false;
|
||||||
document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStopIconSponsorBlocker256px.png");
|
document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStopIconSponsorBlocker256px.png");
|
||||||
document.getElementById("startSponsorButton").setAttribute("title", "Sponsor Ends Now");
|
document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("sponsorEND"));
|
||||||
|
|
||||||
//disable submit button
|
//disable submit button
|
||||||
document.getElementById("submitButton").style.display = "none";
|
document.getElementById("submitButton").style.display = "none";
|
||||||
@@ -812,8 +812,8 @@ function clearSponsorTimes() {
|
|||||||
let sponsorTimes = result[sponsorTimeKey];
|
let sponsorTimes = result[sponsorTimeKey];
|
||||||
|
|
||||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||||
let confirmMessage = "Are you sure you want to clear this?\n\n" + getSponsorTimesMessage(sponsorTimes);
|
let confirmMessage = chrome.i18n.getMessage("clearThis") + getSponsorTimesMessage(sponsorTimes);
|
||||||
confirmMessage += "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner."
|
confirmMessage += chrome.i18n.getMessage("confirmMSG")
|
||||||
if(!confirm(confirmMessage)) return;
|
if(!confirm(confirmMessage)) return;
|
||||||
|
|
||||||
//clear the sponsor times
|
//clear the sponsor times
|
||||||
@@ -894,17 +894,17 @@ function openSkipNotice(UUID){
|
|||||||
buttonContainer.setAttribute("align", "center");
|
buttonContainer.setAttribute("align", "center");
|
||||||
|
|
||||||
let goBackButton = document.createElement("button");
|
let goBackButton = document.createElement("button");
|
||||||
goBackButton.innerText = "Go back";
|
goBackButton.innerText = chrome.i18n.getMessage("goBack");
|
||||||
goBackButton.className = "sponsorSkipButton";
|
goBackButton.className = "sponsorSkipButton";
|
||||||
goBackButton.addEventListener("click", () => goBackToPreviousTime(UUID));
|
goBackButton.addEventListener("click", () => goBackToPreviousTime(UUID));
|
||||||
|
|
||||||
let hideButton = document.createElement("button");
|
let hideButton = document.createElement("button");
|
||||||
hideButton.innerText = "Dismiss";
|
hideButton.innerText = chrome.i18n.getMessage("Dismiss");
|
||||||
hideButton.className = "sponsorSkipButton";
|
hideButton.className = "sponsorSkipButton";
|
||||||
hideButton.addEventListener("click", () => closeSkipNotice(UUID));
|
hideButton.addEventListener("click", () => closeSkipNotice(UUID));
|
||||||
|
|
||||||
let dontShowAgainButton = document.createElement("button");
|
let dontShowAgainButton = document.createElement("button");
|
||||||
dontShowAgainButton.innerText = "Don't Show This Again";
|
dontShowAgainButton.innerText = chrome.i18n.getMessage("Hide");
|
||||||
dontShowAgainButton.className = "sponsorSkipDontShowButton";
|
dontShowAgainButton.className = "sponsorSkipDontShowButton";
|
||||||
dontShowAgainButton.addEventListener("click", dontShowNoticeAgain);
|
dontShowAgainButton.addEventListener("click", dontShowNoticeAgain);
|
||||||
|
|
||||||
@@ -959,12 +959,12 @@ function afterDownvote(UUID) {
|
|||||||
//add thanks for voting text
|
//add thanks for voting text
|
||||||
let thanksForVotingText = document.createElement("p");
|
let thanksForVotingText = document.createElement("p");
|
||||||
thanksForVotingText.id = "sponsorTimesThanksForVotingText";
|
thanksForVotingText.id = "sponsorTimesThanksForVotingText";
|
||||||
thanksForVotingText.innerText = "Thanks for voting!"
|
thanksForVotingText.innerText = chrome.i18n.getMessage("Voted");
|
||||||
|
|
||||||
//add extra info for voting
|
//add extra info for voting
|
||||||
let thanksForVotingInfoText = document.createElement("p");
|
let thanksForVotingInfoText = document.createElement("p");
|
||||||
thanksForVotingInfoText.id = "sponsorTimesThanksForVotingInfoText";
|
thanksForVotingInfoText.id = "sponsorTimesThanksForVotingInfoText";
|
||||||
thanksForVotingInfoText.innerText = "Hit go back to get to where you came from."
|
thanksForVotingInfoText.innerText = chrome.i18n.getMessage("hitGoBack");
|
||||||
|
|
||||||
//add element to div
|
//add element to div
|
||||||
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingText);
|
document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingText);
|
||||||
@@ -1039,15 +1039,14 @@ function vote(type, UUID) {
|
|||||||
}
|
}
|
||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
addLoadingInfo("It seems you've already voted before", UUID)
|
addLoadingInfo(chrome.i18n.getMessage("voteFAIL"), UUID)
|
||||||
} else if (response.successType == -1) {
|
} else if (response.successType == -1) {
|
||||||
if (response.statusCode == 502) {
|
if (response.statusCode == 502) {
|
||||||
addLoadingInfo("It seems the sever is down. Contact the dev immediately.", UUID)
|
addLoadingInfo(chrome.i18n.getMessage("serverDown"), UUID)
|
||||||
} else {
|
} else {
|
||||||
//failure: unknown error
|
//failure: unknown error
|
||||||
addLoadingInfo("A connection error has occured. Error code: " + response.statusCode, UUID)
|
addLoadingInfo(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1157,16 +1156,10 @@ function sendSubmitMessage(){
|
|||||||
document.getElementById("submitButton").style.animation = "unset";
|
document.getElementById("submitButton").style.animation = "unset";
|
||||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
||||||
|
|
||||||
if(response.statusCode == 400) {
|
if([400,429,409,502].includes(response.statusCode)) {
|
||||||
alert("Server said this request was invalid");
|
alert(chrome.i18n.getMessage(response.statusCode));
|
||||||
} else if(response.statusCode == 429) {
|
|
||||||
alert("You have submitted too many sponsor times for this one video, are you sure there are this many?");
|
|
||||||
} else if(response.statusCode == 409) {
|
|
||||||
alert("This has already been submitted before");
|
|
||||||
} else if(response.statusCode == 502) {
|
|
||||||
alert("It seems the server is down. Contact the dev to inform them. Error code " + response.statusCode);
|
|
||||||
} else {
|
} else {
|
||||||
alert("There was an error submitting your sponsor times, please try again later. Error code " + response.statusCode);
|
alert(chrome.i18n.getMessage("connectionError") + response.statusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "SponsorBlock for YouTube - Skip Sponsorships",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "SponsorBlock",
|
"short_name": "__MSG_Name__",
|
||||||
"version": "1.0.36",
|
"version": "1.0.36",
|
||||||
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
"default_locale": "en",
|
||||||
|
"description": "__MSG_Description__",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": [
|
"matches": [
|
||||||
@@ -42,8 +43,8 @@
|
|||||||
"https://sponsor.ajay.app/*"
|
"https://sponsor.ajay.app/*"
|
||||||
],
|
],
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_title": "SponsorBlock",
|
"default_title": "__MSG_Name__",
|
||||||
"default_popup": "popup.html"
|
"default_popup": "__MSG_Popup__"
|
||||||
},
|
},
|
||||||
"background": {
|
"background": {
|
||||||
"scripts":[
|
"scripts":[
|
||||||
|
|||||||
68
popup.js
68
popup.js
@@ -92,15 +92,6 @@ function runThePopup() {
|
|||||||
SB.reportAnIssue.addEventListener("click", reportAnIssue);
|
SB.reportAnIssue.addEventListener("click", reportAnIssue);
|
||||||
SB.hideDiscordButton.addEventListener("click", hideDiscordButton);
|
SB.hideDiscordButton.addEventListener("click", hideDiscordButton);
|
||||||
|
|
||||||
//setup error message languages
|
|
||||||
var EN_US = new Map();
|
|
||||||
|
|
||||||
EN_US.set(400, 'Server said this request was invalid"')
|
|
||||||
.set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?')
|
|
||||||
.set(409, 'This has already been submitted before')
|
|
||||||
.set(502, 'It seems the server is down. Contact the dev to inform them.')
|
|
||||||
.set('Unknown', 'There was an error submitting your sponsor times, please try again later.');
|
|
||||||
|
|
||||||
//if true, the button now selects the end time
|
//if true, the button now selects the end time
|
||||||
let startTimeChosen = false;
|
let startTimeChosen = false;
|
||||||
|
|
||||||
@@ -178,9 +169,9 @@ function runThePopup() {
|
|||||||
chrome.storage.sync.get(["sponsorTimesContributed"], function(result) {
|
chrome.storage.sync.get(["sponsorTimesContributed"], function(result) {
|
||||||
if (result.sponsorTimesContributed != undefined) {
|
if (result.sponsorTimesContributed != undefined) {
|
||||||
if (result.sponsorTimesContributed > 1) {
|
if (result.sponsorTimesContributed > 1) {
|
||||||
SB.sponsorTimesContributionsDisplayEndWord.innerText = "sponsors."
|
SB.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsors");
|
||||||
} else {
|
} else {
|
||||||
SB.sponsorTimesContributionsDisplayEndWord.innerText = "sponsor."
|
SB.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsor");
|
||||||
}
|
}
|
||||||
SB.sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed;
|
SB.sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed;
|
||||||
SB.sponsorTimesContributionsContainer.style.display = "unset";
|
SB.sponsorTimesContributionsContainer.style.display = "unset";
|
||||||
@@ -196,9 +187,9 @@ function runThePopup() {
|
|||||||
let viewCount = JSON.parse(xmlhttp.responseText).viewCount;
|
let viewCount = JSON.parse(xmlhttp.responseText).viewCount;
|
||||||
if (viewCount != 0) {
|
if (viewCount != 0) {
|
||||||
if (viewCount > 1) {
|
if (viewCount > 1) {
|
||||||
SB.sponsorTimesViewsDisplayEndWord.innerText = "sponsor segments."
|
SB.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments");
|
||||||
} else {
|
} else {
|
||||||
SB.sponsorTimesViewsDisplayEndWord.innerText = "sponsor segment."
|
SB.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment");
|
||||||
}
|
}
|
||||||
|
|
||||||
SB.sponsorTimesViewsDisplay.innerText = viewCount;
|
SB.sponsorTimesViewsDisplay.innerText = viewCount;
|
||||||
@@ -219,13 +210,12 @@ function runThePopup() {
|
|||||||
function onTabs(tabs) {
|
function onTabs(tabs) {
|
||||||
chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) {
|
chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) {
|
||||||
if (result != undefined && result.videoID) {
|
if (result != undefined && result.videoID) {
|
||||||
currentVideoID = result.videoID;
|
currentVideoID = result.videoID;
|
||||||
|
loadTabData(tabs);
|
||||||
loadTabData(tabs);
|
|
||||||
} else if (result == undefined && chrome.runtime.lastError) {
|
} else if (result == undefined && chrome.runtime.lastError) {
|
||||||
//this isn't a YouTube video then, or at least the content script is not loaded
|
//this isn't a YouTube video then, or at least the content script is not loaded
|
||||||
displayNoVideo();
|
displayNoVideo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +233,7 @@ function runThePopup() {
|
|||||||
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
||||||
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
|
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
|
||||||
startTimeChosen = true;
|
startTimeChosen = true;
|
||||||
SB.sponsorStart.innerHTML = "Sponsorship Ends Now";
|
SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEND");
|
||||||
}
|
}
|
||||||
|
|
||||||
sponsorTimes = sponsorTimesStorage;
|
sponsorTimes = sponsorTimesStorage;
|
||||||
@@ -283,11 +273,11 @@ function runThePopup() {
|
|||||||
SB.loadingIndicator.innerHTML = "";
|
SB.loadingIndicator.innerHTML = "";
|
||||||
|
|
||||||
if (request.found) {
|
if (request.found) {
|
||||||
SB.videoFound.innerHTML = "This video's sponsors are in the database!"
|
SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
|
||||||
|
|
||||||
displayDownloadedSponsorTimes(request);
|
displayDownloadedSponsorTimes(request);
|
||||||
} else {
|
} else {
|
||||||
SB.videoFound.innerHTML = "No sponsors found"
|
SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +375,7 @@ function runThePopup() {
|
|||||||
function displayDownloadedSponsorTimes(request) {
|
function displayDownloadedSponsorTimes(request) {
|
||||||
if (request.sponsorTimes != undefined) {
|
if (request.sponsorTimes != undefined) {
|
||||||
//set it to the message
|
//set it to the message
|
||||||
if (SB.downloadedSponsorMessageTimes.innerText != "Channel Whitelisted!") {
|
if (SB.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("channelWhitelisted")) {
|
||||||
SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes);
|
SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,8 +644,8 @@ function runThePopup() {
|
|||||||
tabs[0].id,
|
tabs[0].id,
|
||||||
{message: "getCurrentTime"},
|
{message: "getCurrentTime"},
|
||||||
function (response) {
|
function (response) {
|
||||||
let minutes = document.getElementById(idStartName + "Minutes" + index);
|
let minutes = document.getElementById(idStartName + chrome.i18n.getMessage("Mins") + index);
|
||||||
let seconds = document.getElementById(idStartName + "Seconds" + index);
|
let seconds = document.getElementById(idStartName + chrome.i18n.getMessage("Secs") + index);
|
||||||
|
|
||||||
minutes.value = getTimeInMinutes(response.currentTime);
|
minutes.value = getTimeInMinutes(response.currentTime);
|
||||||
seconds.value = getTimeInFormattedSeconds(response.currentTime);
|
seconds.value = getTimeInFormattedSeconds(response.currentTime);
|
||||||
@@ -666,8 +656,8 @@ function runThePopup() {
|
|||||||
//id start name is whether it is the startTime or endTime
|
//id start name is whether it is the startTime or endTime
|
||||||
//gives back the time in seconds
|
//gives back the time in seconds
|
||||||
function getSponsorTimeEditTimes(idStartName, index) {
|
function getSponsorTimeEditTimes(idStartName, index) {
|
||||||
let minutes = document.getElementById(idStartName + "Minutes" + index);
|
let minutes = document.getElementById(idStartName + chrome.i18n.getMessage("Mins") + index);
|
||||||
let seconds = document.getElementById(idStartName + "Seconds" + index);
|
let seconds = document.getElementById(idStartName + chrome.i18n.getMessage("Secs") + index);
|
||||||
|
|
||||||
return parseInt(minutes.value) * 60 + parseFloat(seconds.value);
|
return parseInt(minutes.value) * 60 + parseFloat(seconds.value);
|
||||||
}
|
}
|
||||||
@@ -792,14 +782,9 @@ function runThePopup() {
|
|||||||
resetStartTimeChosen();
|
resetStartTimeChosen();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getErrorMessage(lang, statusCode) {
|
|
||||||
if(lang.has(statusCode)) return lang.get(statusCode);
|
|
||||||
return lang.get('Unknown').concat(" Error code: ") + statusCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitTimes() {
|
function submitTimes() {
|
||||||
//make info message say loading
|
//make info message say loading
|
||||||
SB.submitTimesInfoMessage.innerText = "Loading...";
|
SB.submitTimesInfoMessage.innerText = chrome.i18n.getMessage("Loading");
|
||||||
SB.submitTimesInfoMessageContainer.style.display = "unset";
|
SB.submitTimesInfoMessageContainer.style.display = "unset";
|
||||||
|
|
||||||
if (sponsorTimes.length > 0) {
|
if (sponsorTimes.length > 0) {
|
||||||
@@ -814,7 +799,7 @@ function runThePopup() {
|
|||||||
|
|
||||||
clearTimes();
|
clearTimes();
|
||||||
} else {
|
} else {
|
||||||
let errorMessage = getErrorMessage(EN_US, response.statusCode);
|
let errorMessage = getErrorMessage(response.statusCode);
|
||||||
|
|
||||||
document.getElementById("submitTimesInfoMessage").innerText = errorMessage;
|
document.getElementById("submitTimesInfoMessage").innerText = errorMessage;
|
||||||
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
|
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
|
||||||
@@ -981,7 +966,7 @@ function runThePopup() {
|
|||||||
//update startTimeChosen letiable
|
//update startTimeChosen letiable
|
||||||
if (!startTimeChosen) {
|
if (!startTimeChosen) {
|
||||||
startTimeChosen = true;
|
startTimeChosen = true;
|
||||||
SB.sponsorStart.innerHTML = "Sponsorship Ends Now";
|
SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEND");
|
||||||
} else {
|
} else {
|
||||||
resetStartTimeChosen();
|
resetStartTimeChosen();
|
||||||
}
|
}
|
||||||
@@ -990,7 +975,7 @@ function runThePopup() {
|
|||||||
//set it to false
|
//set it to false
|
||||||
function resetStartTimeChosen() {
|
function resetStartTimeChosen() {
|
||||||
startTimeChosen = false;
|
startTimeChosen = false;
|
||||||
SB.sponsorStart.innerHTML = "Sponsorship Starts Now";
|
SB.sponsorStart.innerHTML = "SP_START";
|
||||||
}
|
}
|
||||||
|
|
||||||
//hides and shows the submit times button when needed
|
//hides and shows the submit times button when needed
|
||||||
@@ -1066,8 +1051,7 @@ function runThePopup() {
|
|||||||
|
|
||||||
//this is not a YouTube video page
|
//this is not a YouTube video page
|
||||||
function displayNoVideo() {
|
function displayNoVideo() {
|
||||||
document.getElementById("loadingIndicator").innerHTML = "This probably isn't a YouTube tab, or you clicked too early. " +
|
document.getElementById("loadingIndicator").innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||||
"If you know this is a YouTube tab, close this popup and open it again.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportAnIssue() {
|
function reportAnIssue() {
|
||||||
@@ -1104,16 +1088,16 @@ function runThePopup() {
|
|||||||
//see if it was a success or failure
|
//see if it was a success or failure
|
||||||
if (response.successType == 1) {
|
if (response.successType == 1) {
|
||||||
//success
|
//success
|
||||||
addVoteMessage("Thanks for voting!", UUID)
|
addVoteMessage(chrome.i18n.getMessage("Voted"), UUID)
|
||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
addVoteMessage("You have already voted this way before.", UUID)
|
addVoteMessage(chrome.i18n.getMessage("voteFAIL"), UUID)
|
||||||
} else if (response.successType == -1) {
|
} else if (response.successType == -1) {
|
||||||
if (response.statusCode == 502) {
|
if (response.statusCode == 502) {
|
||||||
addVoteMessage("It seems the sever is down. Contact the dev immediately.", UUID)
|
addVoteMessage(chrome.i18n.getMessage("serverDown"), UUID)
|
||||||
} else {
|
} else {
|
||||||
//failure: unknown error
|
//failure: unknown error
|
||||||
addVoteMessage("A connection error has occured. Error code: " + response.statusCode, UUID)
|
addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user