aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-23 23:30:11 -0400
committerGitHub <[email protected]>2019-08-23 23:30:11 -0400
commitf0888faf782e71536ae858411866fc71e0b55eb9 (patch)
tree06dd71a15148d21b1598544b347644d53e401486
parent227bec4d8e2391ae1e052096d96385c93c781d0f (diff)
parent9951a1947843abb45c2e156665feb141cbaa82b7 (diff)
downloadSponsorBlock-f0888faf782e71536ae858411866fc71e0b55eb9.tar.gz
SponsorBlock-f0888faf782e71536ae858411866fc71e0b55eb9.zip
Merge pull request #133 from ajayyy/experimental1.1.4
Update master
-rw-r--r--_locales/en/messages.json9
-rw-r--r--_locales/fr/messages.json70
-rw-r--r--background.js20
-rw-r--r--content.js329
-rw-r--r--manifest.json2
-rw-r--r--popup.js4
-rw-r--r--utils.js1
7 files changed, 196 insertions, 239 deletions
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 391c8d5e..f4a08de1 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -124,6 +124,15 @@
"leftTimes": {
"message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)."
},
+ "clearTimes": {
+ "message": "Clear Sponsor Times"
+ },
+ "openPopup": {
+ "message": "Open SponsorBlock Popup"
+ },
+ "SubmitTimes": {
+ "message": "Submit Sponsor Times"
+ },
"submitCheck": {
"message": "Are you sure you want to submit this?"
}
diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json
index e15255f7..a8b8df28 100644
--- a/_locales/fr/messages.json
+++ b/_locales/fr/messages.json
@@ -4,12 +4,12 @@
"description": "Name of the extension."
},
"fullName": {
- "message": "SponsorBlock pour YouTube - Enlève les endossements",
+ "message": "SponsorBlock pour YouTube - Enlève les messages commerciaux et publicités intégrées",
"description": "Name of the extension."
},
"Description": {
- "message": "Enlève les endossements dans les vidéos YouTube. Soummettre les endossements dans les vidéos que vous regardez pour aidez les autres.",
+ "message": "Passe automatiquement les messages commerciaux intégrés dans les vidéos YouTube. Soumettez les segments commerciaux dans les vidéos que vous regardez pour aidez les autres.",
"description": "Description of the extension."
},
"helpPage": {
@@ -19,40 +19,40 @@
"message": "Soumission invalide"
},
"429": {
- "message": "Vous avez soummetez trop de endossements, il y a vraiment cette montant?"
+ "message": "Vous cherchez à envoyer beaucoup de segments, il y en a vraiment autant ?"
},
"409": {
- "message": "Déjas soummis"
+ "message": "Déja soumis"
},
"502": {
- "message": "Le serveur ne fonctionne pas. Message le développeur."
+ "message": "Le serveur ne fonctionne pas. Contactez le développeur."
},
"channelWhitelisted": {
- "message": "Cette channel est sur la liste blanche!"
+ "message": "Cette chaine est sur la liste blanche !"
},
"Sponsor": {
- "message": "endossement"
+ "message": "message commercial"
},
"Sponsors": {
- "message": "endossements"
+ "message": "messages commerciaux"
},
"Segment": {
- "message": "section d'endossement"
+ "message": "segment de message commercial"
},
"Segments": {
- "message": "section d'endossements"
+ "message": "segments de message commercial"
},
"noticeTitle": {
- "message": "Endossement Passer"
+ "message": "Message passé"
},
"reportButtonTitle": {
"message": "Incorrect"
},
"reportButtonInfo": {
- "message": "Informe que cette endossement est incorrect ou n'existe pas."
+ "message": "Signaler que ce segment est incorrect ou n'existe pas."
},
"Dismiss": {
- "message": "Ferme"
+ "message": "Fermer"
},
"Loading": {
"message": "Chargement en cours..."
@@ -61,69 +61,69 @@
"message": "Minutes"
},
"Secs": {
- "message": "Seconds"
+ "message": "Secondes"
},
"Hide": {
- "message": "Ne Montre Jaimais"
+ "message": "Ne plus montrer"
},
"hitGoBack": {
- "message": "Clique retourne pour si vous avez manqué parti."
+ "message": "Cliquez sur revenir en arrière pour revenir avant le saut du segment"
},
"unskip": {
- "message": "Retourne"
+ "message": "Revenir en arrière"
},
"reskip": {
- "message": "Resaute"
+ "message": "Sauter"
},
"paused": {
- "message": "Pause"
+ "message": "En pause"
},
"confirmMSG": {
- "message": "\n\nPour modifier ou enlever des soumissions, clique sur le bouton d'info."
+ "message": "\n\nPour modifier ou enlever des soumissions, cliquez sur le bouton d'info."
},
"clearThis": {
- "message": "Êtes-vous certaines vous voulez enlever vos soumissions?\n\n"
+ "message": "Êtes-vous certain(e) que vous voulez enlever vos soumissions ?\n\n"
},
"Unknown": {
- "message": "Erreur, essayer encore plus tard."
+ "message": "Erreur, essayer plus tard."
},
"sponsorFound": {
- "message": "Cette vidéo est dans le database!"
+ "message": "Les messages commerciaux sont déjà dans notre base de donnée pour cette vidéo !"
},
"sponsor404": {
- "message": "Rien d'endossements trouvé"
+ "message": "Pas de messages trouvés"
},
"sponsorStart": {
- "message": "Endossement Commence Maintenant"
+ "message": "Début du message"
},
"sponsorEnd": {
- "message": "Endossement Arête Maintenant"
+ "message": "Fin du message"
},
"noVideoID": {
- "message": "Ceci n'est pas une tab de YouTube, ou vous avez cliqué trop tôt. \n Si vous savez que ceci est une tab YouTube, ferme ce menu et essayé encore."
+ "message": "Ceci n'est pas un onglet YouTube, ou vous avez cliqué trop tôt. \n Si vous êtes sur(e) que c'est un onglet YouTube, fermez ce menu et réessayer."
},
"success": {
- "message": "Succès!"
+ "message": "Succès !"
},
"voted": {
- "message": "Voté!"
+ "message": "A voté !"
},
"voteFail": {
- "message": "Vous avez déjà voté la même façon."
+ "message": "Vous avez déjà voté pour ce choix auparavant."
},
"serverDown": {
- "message": "Le serveur ne fonctionne pas. Message le développeur."
+ "message": "Le serveur ne fonctionne pas. Contactez le développeur."
},
"connectionError": {
- "message": "Erreur. Code: "
+ "message": "Erreur de connexion, Code : "
},
"wantToSubmit": {
- "message": "Voulez-vous soumettre les endossements sur le vidéo"
+ "message": "Voulez-vous soumettre les messages pour cette vidéo"
},
"leftTimes": {
- "message": "Vous avez laissé les endossements qui n'étaient pas soumis. Retournez à la page pour les soumettre (Ils ne sont pas enlevés)."
+ "message": "Vous avez laissé des messages non soumis. Retournez sur la vidéo pour les soumettre (ils ont été conservés)."
},
"submitCheck": {
- "message": "Êtes-vous certaines vous voulez soumettre?"
+ "message": "Soumettre ce(s) message(s) ?"
}
}
diff --git a/background.js b/background.js
index 64c7813c..aa25e379 100644
--- a/background.js
+++ b/background.js
@@ -147,11 +147,29 @@ function submitVote(type, UUID, callback) {
function submitTimes(videoID, callback) {
//get the video times from storage
let sponsorTimeKey = 'sponsorTimes' + videoID;
- chrome.storage.sync.get([sponsorTimeKey, "userID"], function(result) {
+ chrome.storage.sync.get([sponsorTimeKey, "userID"], async function(result) {
let sponsorTimes = result[sponsorTimeKey];
let userID = result.userID;
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
+ let durationResult = await new Promise((resolve, reject) => {
+ chrome.tabs.query({
+ active: true,
+ currentWindow: true
+ }, function(tabs) {
+ chrome.tabs.sendMessage(tabs[0].id, {
+ message: "getVideoDuration"
+ }, (response) => resolve(response));
+ });
+ });
+
+ //check if a sponsor exceeds the duration of the video
+ for (let i = 0; i < sponsorTimes.length; i++) {
+ if (sponsorTimes[i][1] > durationResult.duration) {
+ sponsorTimes[i][1] = durationResult.duration;
+ }
+ }
+
//submit these times
for (let i = 0; i < sponsorTimes.length; i++) {
//submit the sponsorTime
diff --git a/content.js b/content.js
index e88b602b..2be7ce4d 100644
--- a/content.js
+++ b/content.js
@@ -28,11 +28,13 @@ var channelURL;
var channelWhitelisted = false;
// create preview bar
-var previewBar;
+var previewBar = null;
-if (id = getYouTubeVideoID(document.URL)) { // Direct Links
- videoIDChange(id);
-}
+//the player controls on the YouTube player
+var controls = null;
+
+// Direct Links
+videoIDChange(getYouTubeVideoID(document.URL));
//the last time looked at (used to see if this time is in the interval)
var lastTime = -1;
@@ -90,11 +92,7 @@ function messageListener(request, sender, sendResponse) {
//messages from popup script
if (request.message == "update") {
- if(id = getYouTubeVideoID(document.URL)){
- videoIDChange(id);
- } else {
- resetValues();
- }
+ videoIDChange(getYouTubeVideoID(document.URL));
}
if (request.message == "sponsorStart") {
@@ -124,10 +122,16 @@ function messageListener(request, sender, sendResponse) {
if (request.message == "getVideoID") {
sendResponse({
- videoID: getYouTubeVideoID(document.URL)
+ videoID: sponsorVideoID
})
}
+ if (request.message == "getVideoDuration") {
+ sendResponse({
+ duration: v.duration
+ });
+ }
+
if (request.message == "skipToTime") {
v.currentTime = request.time;
}
@@ -152,7 +156,7 @@ function messageListener(request, sender, sendResponse) {
if (request.message == "whitelistChange") {
channelWhitelisted = request.value;
- sponsorsLookup(getYouTubeVideoID(document.URL));
+ sponsorsLookup(sponsorVideoID);
}
if (request.message == "showNoticeAgain") {
@@ -208,20 +212,30 @@ function resetValues() {
//reset sponsor times
sponsorTimes = null;
UUIDs = null;
- sponsorVideoID = id;
sponsorLookupRetries = 0;
//empty the preview bar
- previewBar.set([], [], 0);
+ if (previewBar !== null) {
+ previewBar.set([], [], 0);
+ }
//reset sponsor data found check
sponsorDataFound = false;
}
function videoIDChange(id) {
- //not a url change
- if (sponsorVideoID == id) return;
+ //if the id has not changed return
+ if (sponsorVideoID === id) return;
+
+ //set the global videoID
+ sponsorVideoID = id;
+ resetValues();
+
+ //id is not valid
+ if (!id) return;
+
+ //setup the preview bar
if (previewBar == null) {
//create it
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
@@ -253,9 +267,7 @@ function videoIDChange(id) {
//close popup
closeInfoMenu();
-
- resetValues();
-
+
sponsorsLookup(id);
//make sure everything is properly added
@@ -265,28 +277,30 @@ function videoIDChange(id) {
sponsorTimesSubmitting = [];
//see if the onvideo control image needs to be changed
- chrome.runtime.sendMessage({
- message: "getSponsorTimes",
- videoID: id
- }, function(response) {
- if (response != undefined) {
- let sponsorTimes = response.sponsorTimes;
- if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) {
- changeStartSponsorButton(true, true);
- } else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
- changeStartSponsorButton(false, true);
- } else {
- changeStartSponsorButton(true, false);
- }
-
- //see if this data should be saved in the sponsorTimesSubmitting variable
- if (sponsorTimes != undefined && sponsorTimes.length > 0) {
- sponsorTimesSubmitting = sponsorTimes;
-
- updatePreviewBar();
- }
- }
- });
+ wait(getControls).then(result => {
+ chrome.runtime.sendMessage({
+ message: "getSponsorTimes",
+ videoID: id
+ }, function(response) {
+ if (response != undefined) {
+ let sponsorTimes = response.sponsorTimes;
+ if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) {
+ changeStartSponsorButton(true, true);
+ } else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
+ changeStartSponsorButton(false, true);
+ } else {
+ changeStartSponsorButton(true, false);
+ }
+
+ //see if this data should be saved in the sponsorTimesSubmitting variable
+ if (sponsorTimes != undefined && sponsorTimes.length > 0) {
+ sponsorTimesSubmitting = sponsorTimes;
+
+ updatePreviewBar();
+ }
+ }
+ });
+ });
//see if video controls buttons should be added
chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
@@ -329,6 +343,9 @@ function sponsorsLookup(id) {
}
//check database for sponsor times
+
+ //made true once a setTimeout has been created to try again after a server error
+ let recheckStarted = false;
sendRequestToServer('GET', "/api/getVideoSponsorTimes?videoID=" + id, function(xmlhttp) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
sponsorDataFound = true;
@@ -364,7 +381,9 @@ function sponsorsLookup(id) {
});
sponsorLookupRetries = 0;
- } else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90) {
+ } else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90 && !recheckStarted) {
+ recheckStarted = true;
+
//some error occurred, try again in a second
setTimeout(() => sponsorsLookup(id), 1000);
@@ -396,7 +415,7 @@ function updatePreviewBar() {
previewBar.set(allSponsorTimes, types, v.duration);
//update last video id
- lastPreviewBarUpdate = getYouTubeVideoID(document.URL);
+ lastPreviewBarUpdate = sponsorVideoID;
}
function getChannelID() {
@@ -539,55 +558,63 @@ function reskipSponsorTime(UUID) {
}
}
-//Adds a sponsorship starts button to the player controls
-function addPlayerControlsButton() {
- if (document.getElementById("startSponsorButton") != null) {
- //it's already added
- return;
- }
+function removePlayerControlsButton() {
+ if (!sponsorVideoID) return;
- let startSponsorButton = document.createElement("button");
- startSponsorButton.id = "startSponsorButton";
- startSponsorButton.draggable = false;
- startSponsorButton.className = "ytp-button playerButton";
- startSponsorButton.setAttribute("title", chrome.i18n.getMessage("sponsorStart"));
- startSponsorButton.addEventListener("click", startSponsorClicked);
+ document.getElementById("startSponsorButton").style.display = "none";
+ document.getElementById("submitButton").style.display = "none";
+}
- let startSponsorImage = document.createElement("img");
- startSponsorImage.id = "startSponsorImage";
- startSponsorImage.draggable = false;
- startSponsorImage.className = "playerButtonImage";
- startSponsorImage.src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
+function createButton(baseID, title, callback, imageName, isDraggable=false) {
+ if (document.getElementById(baseID + "Button") != null) return;
- //add the image to the button
- startSponsorButton.appendChild(startSponsorImage);
+ // Button HTML
+ let newButton = document.createElement("button");
+ newButton.draggable = isDraggable;
+ newButton.id = baseID + "Button";
+ newButton.className = "ytp-button playerButton";
+ newButton.setAttribute("title", chrome.i18n.getMessage(title));
+ newButton.addEventListener("click", callback);
- let controls = document.getElementsByClassName("ytp-right-controls");
- let referenceNode = controls[controls.length - 1];
+ // Image HTML
+ let newButtonImage = document.createElement("img");
+ newButton.draggable = isDraggable;
+ newButtonImage.id = baseID + "Image";
+ newButtonImage.className = "playerButtonImage";
+ newButtonImage.src = chrome.extension.getURL("icons/" + imageName);
- if (referenceNode == undefined) {
- //page not loaded yet
- setTimeout(addPlayerControlsButton, 100);
- return;
- }
+ // Append image to button
+ newButton.appendChild(newButtonImage);
- referenceNode.prepend(startSponsorButton);
+ // Add the button to player
+ controls.prepend(newButton);
}
-function removePlayerControlsButton() {
- document.getElementById("startSponsorButton").style.display = "none";
- document.getElementById("submitButton").style.display = "none";
+function getControls() {
+ let controls = document.getElementsByClassName("ytp-right-controls");
+ return (!controls || controls.length === 0) ? false : controls[controls.length - 1]
+};
+
+//adds all the player controls buttons
+function createButtons() {
+ wait(getControls).then(result => {
+ //set global controls variable
+ controls = result;
+
+ // Add button if does not already exist in html
+ createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png");
+ createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png")
+ createButton("delete", "clearTimes", clearSponsorTimes, "PlayerDeleteIconSponsorBlocker256px.png");
+ createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker256px.png");
+ });
}
-
//adds or removes the player controls button to what it should be
function updateVisibilityOfPlayerControlsButton() {
//not on a proper video yet
- if (!getYouTubeVideoID(document.URL)) return;
+ if (!sponsorVideoID) return;
- addPlayerControlsButton();
- addInfoButton();
- addDeleteButton();
- addSubmitButton();
+ createButtons();
+
if (hideVideoPlayerControls) {
removePlayerControlsButton();
}
@@ -609,7 +636,7 @@ function startSponsorClicked() {
chrome.runtime.sendMessage({
message: "addSponsorTime",
time: v.currentTime,
- videoID: getYouTubeVideoID(document.URL)
+ videoID: sponsorVideoID
}, function(response) {
//see if the sponsorTimesSubmitting needs to be updated
updateSponsorTimesSubmitting();
@@ -619,7 +646,7 @@ function startSponsorClicked() {
function updateSponsorTimesSubmitting() {
chrome.runtime.sendMessage({
message: "getSponsorTimes",
- videoID: getYouTubeVideoID(document.URL)
+ videoID: sponsorVideoID
}, function(response) {
if (response != undefined) {
let sponsorTimes = response.sponsorTimes;
@@ -634,13 +661,17 @@ function updateSponsorTimesSubmitting() {
});
}
+//is the submit button on the player loaded yet
+function isSubmitButtonLoaded() {
+ return document.getElementById("submitButton") !== null;
+}
+
function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
+ if(!sponsorVideoID) return false;
+ wait(isSubmitButtonLoaded).then(result => {
//if it isn't visible, there is no data
- if (uploadButtonVisible && !hideDeleteButtonPlayerControls) {
- document.getElementById("deleteButton").style.display = "unset";
- } else {
- document.getElementById("deleteButton").style.display = "none";
- }
+ let shouldHide = (uploadButtonVisible && !hideDeleteButtonPlayerControls) ? "unset":"none"
+ document.getElementById("deleteButton").style.display = shouldHide;
if (showStartSponsor) {
showingStartSponsor = true;
@@ -661,124 +692,13 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
//disable submit button
document.getElementById("submitButton").style.display = "none";
}
+ });
}
function toggleStartSponsorButton() {
changeStartSponsorButton(!showingStartSponsor, true);
}
-//shows the info button on the video player
-function addInfoButton() {
- if (document.getElementById("infoButton") != null) {
- //it's already added
- return;
- }
-
- //make a submit button
- let infoButton = document.createElement("button");
- infoButton.id = "infoButton";
- infoButton.draggable = false;
- infoButton.className = "ytp-button playerButton";
- infoButton.setAttribute("title", "Open SponsorBlock Popup");
- infoButton.addEventListener("click", openInfoMenu);
-
- let infoImage = document.createElement("img");
- infoImage.id = "infoButtonImage";
- infoImage.draggable = false;
- infoImage.className = "playerButtonImage";
- infoImage.src = chrome.extension.getURL("icons/PlayerInfoIconSponsorBlocker256px.png");
-
- //add the image to the button
- infoButton.appendChild(infoImage);
-
- let controls = document.getElementsByClassName("ytp-right-controls");
- let referenceNode = controls[controls.length - 1];
-
- if (referenceNode == undefined) {
- //page not loaded yet
- setTimeout(addInfoButton, 100);
- return;
- }
-
- referenceNode.prepend(infoButton);
-}
-
-//shows the delete button on the video player
-function addDeleteButton() {
- if (document.getElementById("deleteButton") != null) {
- //it's already added
- return;
- }
-
- //make a submit button
- let deleteButton = document.createElement("button");
- deleteButton.id = "deleteButton";
- deleteButton.draggable = false;
- deleteButton.className = "ytp-button playerButton";
- deleteButton.setAttribute("title", "Clear Sponsor Times");
- deleteButton.addEventListener("click", clearSponsorTimes);
- //hide it at the start
- deleteButton.style.display = "none";
-
- let deleteImage = document.createElement("img");
- deleteImage.id = "deleteButtonImage";
- deleteImage.draggable = false;
- deleteImage.className = "playerButtonImage";
- deleteImage.src = chrome.extension.getURL("icons/PlayerDeleteIconSponsorBlocker256px.png");
-
- //add the image to the button
- deleteButton.appendChild(deleteImage);
-
- let controls = document.getElementsByClassName("ytp-right-controls");
- let referenceNode = controls[controls.length - 1];
-
- if (referenceNode == undefined) {
- //page not loaded yet
- setTimeout(addDeleteButton, 100);
- return;
- }
-
- referenceNode.prepend(deleteButton);
-}
-
-//shows the submit button on the video player
-function addSubmitButton() {
- if (document.getElementById("submitButton") != null) {
- //it's already added
- return;
- }
-
- //make a submit button
- let submitButton = document.createElement("button");
- submitButton.id = "submitButton";
- submitButton.draggable = false;
- submitButton.className = "ytp-button playerButton";
- submitButton.setAttribute("title", "Submit Sponsor Times");
- submitButton.addEventListener("click", submitSponsorTimes);
- //hide it at the start
- submitButton.style.display = "none";
-
- let submitImage = document.createElement("img");
- submitImage.id = "submitButtonImage";
- submitImage.draggable = false;
- submitImage.className = "playerButtonImage";
- submitImage.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
-
- //add the image to the button
- submitButton.appendChild(submitImage);
-
- let controls = document.getElementsByClassName("ytp-right-controls");
- let referenceNode = controls[controls.length - 1];
-
- if (referenceNode == undefined) {
- //page not loaded yet
- setTimeout(addSubmitButton, 100);
- return;
- }
-
- referenceNode.prepend(submitButton);
-}
-
function openInfoMenu() {
if (document.getElementById("sponsorBlockPopupContainer") != null) {
//it's already added
@@ -843,7 +763,7 @@ function clearSponsorTimes() {
//it can't update to this info yet
closeInfoMenu();
- let currentVideoID = getYouTubeVideoID(document.URL);
+ let currentVideoID = sponsorVideoID;
let sponsorTimeKey = 'sponsorTimes' + currentVideoID;
chrome.storage.sync.get([sponsorTimeKey], function(result) {
@@ -946,13 +866,22 @@ function submitSponsorTimes() {
//it can't update to this info yet
closeInfoMenu();
- let currentVideoID = getYouTubeVideoID(document.URL);
+ let currentVideoID = sponsorVideoID;
let sponsorTimeKey = 'sponsorTimes' + currentVideoID;
chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimes = result[sponsorTimeKey];
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
+ //check if a sponsor exceeds the duration of the video
+ for (let i = 0; i < sponsorTimes.length; i++) {
+ if (sponsorTimes[i][1] > v.duration) {
+ sponsorTimes[i][1] = v.duration;
+ }
+ }
+ //update sponsorTimes
+ chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
+
let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes);
confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG");
if(!confirm(confirmMessage)) return;
@@ -970,7 +899,7 @@ function sendSubmitMessage(){
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite";
- let currentVideoID = getYouTubeVideoID(document.URL);
+ let currentVideoID = sponsorVideoID;
chrome.runtime.sendMessage({
message: "submitTimes",
diff --git a/manifest.json b/manifest.json
index 9b803b07..d9dc24d5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_fullName__",
"short_name": "__MSG_Name__",
- "version": "1.1.3",
+ "version": "1.1.4",
"default_locale": "en",
"description": "__MSG_Description__",
"content_scripts": [
diff --git a/popup.js b/popup.js
index e8d1c59d..39358977 100644
--- a/popup.js
+++ b/popup.js
@@ -981,7 +981,7 @@ function runThePopup() {
//set it to false
function resetStartTimeChosen() {
startTimeChosen = false;
- SB.sponsorStart.innerHTML = "SP_START";
+ SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorStart");
}
//hides and shows the submit times button when needed
@@ -1278,7 +1278,7 @@ function runThePopup() {
if (chrome.tabs != undefined) {
//add the width restriction (because Firefox)
- document.getElementById("sponorBlockStyleSheet").sheet.insertRule('.popupBody { width: 300 }', 0);
+ document.getElementById("sponorBlockStyleSheet").sheet.insertRule('.popupBody { width: 325 }', 0);
//this means it is actually opened in the popup
runThePopup();
diff --git a/utils.js b/utils.js
index e0954047..5fa60564 100644
--- a/utils.js
+++ b/utils.js
@@ -37,4 +37,5 @@ function getYouTubeVideoID(url) {
return false;
}
}
+ return false;
} \ No newline at end of file