From a2312a10be29fcb99eba9993294384ea560624ba Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 28 Jul 2019 17:22:05 -0400 Subject: [PATCH 1/2] Fixed an issue on Firefox where the old video's sponsors would sometimes play on the next video. --- content.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/content.js b/content.js index 23c08036..7f6f3878 100644 --- a/content.js +++ b/content.js @@ -1,13 +1,15 @@ -if(id = getYouTubeVideoID(document.URL)){ // Direct Links - videoIDChange(id); -} - //was sponsor data found when doing SponsorsLookup var sponsorDataFound = false; //the actual sponsorTimes if loaded and UUIDs associated with them -var sponsorTimes = undefined; -var UUIDs = undefined; +var sponsorTimes = null; +var UUIDs = null; +//what video id are these sponsors for +var sponsorVideoID = null; + +if(id = getYouTubeVideoID(document.URL)){ // Direct Links + videoIDChange(id); +} //the video var v; @@ -53,6 +55,7 @@ chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { chrome.runtime.onMessage.addListener( // Detect URL Changes function(request, sender, sendResponse) { + console.log(request.message) //message from background script if (request.message == "ytvideoid") { videoIDChange(request.id); @@ -117,13 +120,19 @@ document.onkeydown = function(e){ } function videoIDChange(id) { + //not a url change + if (sponsorVideoID == id){ + return; + } + //reset last sponsor times lastTime = -1; lastUnixTimeSkipped = -1; //reset sponsor times - sponsorTimes = undefined; - UUIDs = undefined; + sponsorTimes = null; + UUIDs = null; + sponsorVideoID = id; //reset sponsor data found check sponsorDataFound = false; @@ -136,9 +145,9 @@ function videoIDChange(id) { }, function(response) { if (response != undefined) { let sponsorTimes = response.sponsorTimes; - if (sponsorTimes != undefined && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) { + if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) { document.getElementById("submitButton").style.display = "unset"; - } else if (sponsorTimes != undefined && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) { + } else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) { toggleStartSponsorButton(); } } @@ -232,7 +241,7 @@ function sponsorCheck(sponsorTimes) { // Video skipping } function goBackToPreviousTime(UUID) { - if (sponsorTimes != undefined) { + if (sponsorTimes != null) { //add a tiny bit of time to make sure it is not skipped again v.currentTime = sponsorTimes[UUIDs.indexOf(UUID)][0] + 0.001; @@ -593,12 +602,10 @@ function sponsorMessageStarted() { } function submitSponsorTimes() { - console.log("Tessst") if (document.getElementById("submitButton").style.display == "none") { //don't submit, not ready return; } - console.log("Test") //add loading animation document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png"); From e749456719b430d6b98c3be4c2205b472ace3479 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 28 Jul 2019 17:23:01 -0400 Subject: [PATCH 2/2] Updated version number. --- firefox_manifest.json | 2 +- manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firefox_manifest.json b/firefox_manifest.json index 7021c6ff..4c2a0bad 100644 --- a/firefox_manifest.json +++ b/firefox_manifest.json @@ -1,7 +1,7 @@ { "name": "SponsorBlock - YouTube Sponsorship Blocker", "short_name": "SponsorBlock", - "version": "1.0.10", + "version": "1.0.12", "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "content_scripts": [ { diff --git a/manifest.json b/manifest.json index 8a397921..2287e4d3 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "SponsorBlock - YouTube Sponsorship Blocker", "short_name": "SponsorBlock", - "version": "1.0.10", + "version": "1.0.12", "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "content_scripts": [ {