mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-28 13:20:51 +03:00
CC
This commit is contained in:
39
popup.js
39
popup.js
@@ -200,13 +200,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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +223,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;
|
||||||
@@ -264,11 +263,11 @@ function runThePopup() {
|
|||||||
SB.loadingIndicator.innerHTML = "";
|
SB.loadingIndicator.innerHTML = "";
|
||||||
|
|
||||||
if (request.found) {
|
if (request.found) {
|
||||||
SB.videoFound.innerHTML = chrome.i18n.getMessage("SponsorFound");
|
SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
|
||||||
|
|
||||||
displayDownloadedSponsorTimes(request);
|
displayDownloadedSponsorTimes(request);
|
||||||
} else {
|
} else {
|
||||||
SB.videoFound.innerHTML = chrome.i18n.getMessage("Sponsor404");
|
SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +365,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 != chrome.i18n.getMessage("ChannelWhitelisted")) {
|
if (SB.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("channelWhitelisted")) {
|
||||||
SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes);
|
SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,8 +627,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);
|
||||||
@@ -640,8 +639,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);
|
||||||
}
|
}
|
||||||
@@ -768,7 +767,7 @@ function runThePopup() {
|
|||||||
|
|
||||||
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) {
|
||||||
@@ -950,7 +949,7 @@ function runThePopup() {
|
|||||||
//update startTimeChosen letiable
|
//update startTimeChosen letiable
|
||||||
if (!startTimeChosen) {
|
if (!startTimeChosen) {
|
||||||
startTimeChosen = true;
|
startTimeChosen = true;
|
||||||
SB.sponsorStart.innerHTML = chrome.i18n.getMessage("SponsorEND");
|
SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEND");
|
||||||
} else {
|
} else {
|
||||||
resetStartTimeChosen();
|
resetStartTimeChosen();
|
||||||
}
|
}
|
||||||
@@ -982,7 +981,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 = chrome.i18n.getMessage("Sponsor404");
|
document.getElementById("loadingIndicator").innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportAnIssue() {
|
function reportAnIssue() {
|
||||||
@@ -1019,13 +1018,13 @@ 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(chrome.i18n.getMessage("VOTED"), UUID)
|
addVoteMessage(chrome.i18n.getMessage("Voted"), UUID)
|
||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
addVoteMessage(chrome.i18n.getMessage("VOTE_FAIL"), 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(chrome.i18n.getMessage("ServerDown"), UUID)
|
addVoteMessage(chrome.i18n.getMessage("serverDown"), UUID)
|
||||||
} else {
|
} else {
|
||||||
//failure: unknown error
|
//failure: unknown error
|
||||||
addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID)
|
addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID)
|
||||||
|
|||||||
Reference in New Issue
Block a user