From 62632792cc210311f5253361b90bd0ddcba165b6 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 13:28:50 +0100 Subject: [PATCH 01/26] Removed tabs permission --- manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.json b/manifest.json index 1fe36a7c..0f48727c 100644 --- a/manifest.json +++ b/manifest.json @@ -37,7 +37,6 @@ "help/style.css" ], "permissions": [ - "tabs", "storage", "notifications", "https://sponsor.ajay.app/*" From 077efd2de3e3428b044785b93ffd97e4e65d33a9 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 14:02:06 +0100 Subject: [PATCH 02/26] Moving to content script --- content.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content.js b/content.js index 73348973..d124217b 100644 --- a/content.js +++ b/content.js @@ -80,8 +80,8 @@ chrome.runtime.onMessage.addListener(messageListener); function messageListener(request, sender, sendResponse) { //message from background script - if (request.message == "ytvideoid") { - videoIDChange(request.id); + if (request.message == "TabUpdate") { + if(id = getYouTubeVideoID(document.URL)) videoIDChange(id); } //messages from popup script @@ -1165,4 +1165,4 @@ function getYouTubeVideoStartTime(url) { } return startTime; -} \ No newline at end of file +} From 410f5fc138be744b06e38f322734b6e52221b6a7 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 14:03:13 +0100 Subject: [PATCH 03/26] Update background.js --- background.js | 60 +++++++-------------------------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/background.js b/background.js index cbd45531..6a1d972b 100644 --- a/background.js +++ b/background.js @@ -10,24 +10,17 @@ var sponsorVideoID = null; chrome.tabs.onActivated.addListener( function(activeInfo) { chrome.tabs.get(activeInfo.tabId, function(tab) { - let id = getYouTubeVideoID(tab.url); - - //if this even is a YouTube tab - if (id) { - videoIDChange(id, activeInfo.tabId); - } + TabUpdate(activeInfo.tabId); }) } ); //when a tab changes URLs chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { - if (changeInfo != undefined && changeInfo.url != undefined) { - let id = getYouTubeVideoID(changeInfo.url); - - //if URL changed and is youtube video message contentScript the video id - if (changeInfo.url && id) { - videoIDChange(id, tabId); + if (changeInfo != undefined) { + //if URL changed + if (tabId) { + TabUpdate(tabId); } } }); @@ -176,42 +169,11 @@ function submitTimes(videoID, callback) { }); } -function videoIDChange(currentVideoID, tabId) { +function TabUpdate(tabId) { //send a message to the content script chrome.tabs.sendMessage(tabId, { - message: 'ytvideoid', - id: currentVideoID + message: 'update' }); - - //not a url change - if (sponsorVideoID == currentVideoID){ - return; - } - sponsorVideoID = currentVideoID; - - //warn them if they had unsubmitted times - if (previousVideoID != null) { - //get the sponsor times from storage - let sponsorTimeKey = 'sponsorTimes' + previousVideoID; - chrome.storage.sync.get([sponsorTimeKey], function(result) { - let sponsorTimes = result[sponsorTimeKey]; - - if (sponsorTimes != undefined && sponsorTimes.length > 0) { - //warn them that they have unsubmitted sponsor times - chrome.notifications.create("stillThere" + Math.random(), { - type: "basic", - title: "Do you want to submit the sponsor times for watch?v=" + previousVideoID + "?", - message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", - iconUrl: "./icons/LogoSponsorBlocker256px.png" - }); - } - - //set the previous video id to the currentID - previousVideoID = currentVideoID; - }); - } else { - previousVideoID = currentVideoID; - } } function getUserID(callback) { @@ -263,11 +225,5 @@ function sendRequestToServer(type, address, callback) { xmlhttp.send(); } -function getYouTubeVideoID(url) { // Return video id or false - var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; - var match = url.match(regExp); - return (match && match[7].length == 11) ? match[7] : false; -} - //uuid generator function from https://gist.github.com/jed/982883 -function generateUUID(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,generateUUID)} \ No newline at end of file +function generateUUID(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,generateUUID)} From 2067b1c78706012b4451a1168485abf3ea7ea42b Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 14:04:21 +0100 Subject: [PATCH 04/26] Removed unused lines --- background.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/background.js b/background.js index 6a1d972b..cc45246f 100644 --- a/background.js +++ b/background.js @@ -1,11 +1,6 @@ -var previousVideoID = null - //the id of this user, randomly generated once per install var userID = null; -//the last video id loaded, to make sure it is a video id change -var sponsorVideoID = null; - //when a new tab is highlighted chrome.tabs.onActivated.addListener( function(activeInfo) { From a9ea22f5050c205084685a586d91c800cfa11b93 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 14:43:15 +0100 Subject: [PATCH 05/26] Get ID from storage API --- popup.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/popup.js b/popup.js index 8368f274..8da7330d 100644 --- a/popup.js +++ b/popup.js @@ -221,16 +221,18 @@ function runThePopup() { } }); - chrome.tabs.query({ active: true, currentWindow: true }, loadTabData); + function OnTabs(tabs) { + chrome.storage.sync.get(['videoid'], function(result) { + loadTabData(tabs, result.videoid); + }); + } - function loadTabData(tabs) { - //set current videoID - currentVideoID = getYouTubeVideoID(tabs[0].url); + function loadTabData(tabs, currentVideoID) { if (!currentVideoID) { //this isn't a YouTube video then @@ -1143,4 +1145,4 @@ if (chrome.tabs != undefined) { //this means it is actually opened in the popup runThePopup(); -} \ No newline at end of file +} From 22e7c6a40d6af9a8523aabfa201380c65a8f1dc9 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 14:44:48 +0100 Subject: [PATCH 06/26] Sync Video ID with Storage API --- content.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content.js b/content.js index d124217b..d1fdd32c 100644 --- a/content.js +++ b/content.js @@ -179,11 +179,12 @@ document.onkeydown = function(e){ } function videoIDChange(id) { - //not a url change - if (sponsorVideoID == id){ - return; - } + //not a url change + if (sponsorVideoID == id) return; + + chrome.storage.sync.set({videoid: id}); + //close popup closeInfoMenu(); From 4c12bb9c2f5863fbbbecdc988c072ed6e29e8900 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 16:45:23 +0100 Subject: [PATCH 07/26] camelCase --- background.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index cc45246f..9640bec5 100644 --- a/background.js +++ b/background.js @@ -5,7 +5,7 @@ var userID = null; chrome.tabs.onActivated.addListener( function(activeInfo) { chrome.tabs.get(activeInfo.tabId, function(tab) { - TabUpdate(activeInfo.tabId); + tabUpdate(activeInfo.tabId); }) } ); @@ -15,7 +15,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (changeInfo != undefined) { //if URL changed if (tabId) { - TabUpdate(tabId); + tabUpdate(tabId); } } }); @@ -164,7 +164,7 @@ function submitTimes(videoID, callback) { }); } -function TabUpdate(tabId) { +function tabUpdate(tabId) { //send a message to the content script chrome.tabs.sendMessage(tabId, { message: 'update' From 2a64afe9dc978b5acdd8a4dc0831ff71eb32ef9f Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 16:48:00 +0100 Subject: [PATCH 08/26] camelCase --- popup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/popup.js b/popup.js index 8da7330d..dda77b3a 100644 --- a/popup.js +++ b/popup.js @@ -226,7 +226,7 @@ function runThePopup() { currentWindow: true }, loadTabData); - function OnTabs(tabs) { + function onTabs(tabs) { chrome.storage.sync.get(['videoid'], function(result) { loadTabData(tabs, result.videoid); }); From 074f7c5456d56fd2a7b11bcc639bfaf876a772ba Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 16:50:33 +0100 Subject: [PATCH 09/26] Switched callback to onTabs --- popup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/popup.js b/popup.js index dda77b3a..e1a63818 100644 --- a/popup.js +++ b/popup.js @@ -224,11 +224,11 @@ function runThePopup() { chrome.tabs.query({ active: true, currentWindow: true - }, loadTabData); + }, onTabs); function onTabs(tabs) { chrome.storage.sync.get(['videoid'], function(result) { - loadTabData(tabs, result.videoid); + loadTabData(tabs, result.videoid); }); } From e1f1814748f8ca74ad7fe9d4e0e1547d2e206f37 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 17:03:58 +0100 Subject: [PATCH 10/26] Moved code from background.js --- content.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/content.js b/content.js index d1fdd32c..a21c3164 100644 --- a/content.js +++ b/content.js @@ -184,6 +184,30 @@ function videoIDChange(id) { if (sponsorVideoID == id) return; chrome.storage.sync.set({videoid: id}); + + //warn them if they had unsubmitted times + if (previousVideoID != null) { + //get the sponsor times from storage + let sponsorTimeKey = 'sponsorTimes' + previousVideoID; + chrome.storage.sync.get([sponsorTimeKey], function(result) { + let sponsorTimes = result[sponsorTimeKey]; + + if (sponsorTimes != undefined && sponsorTimes.length > 0) { + //warn them that they have unsubmitted sponsor times + chrome.notifications.create("stillThere" + Math.random(), { + type: "basic", + title: "Do you want to submit the sponsor times for watch?v=" + previousVideoID + "?", + message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", + iconUrl: "./icons/LogoSponsorBlocker256px.png" + }); + } + + //set the previous video id to the currentID + previousVideoID = id; + }); + } else { + previousVideoID = id; + } //close popup closeInfoMenu(); From 301e16b8f13bdf060e99acb9f60b9d65e33bc8de Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 19:25:29 +0100 Subject: [PATCH 11/26] Removed tabUpdate as detecting in contentscript --- background.js | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/background.js b/background.js index 9640bec5..adafe098 100644 --- a/background.js +++ b/background.js @@ -1,24 +1,8 @@ //the id of this user, randomly generated once per install var userID = null; -//when a new tab is highlighted -chrome.tabs.onActivated.addListener( - function(activeInfo) { - chrome.tabs.get(activeInfo.tabId, function(tab) { - tabUpdate(activeInfo.tabId); - }) - } -); - -//when a tab changes URLs -chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { - if (changeInfo != undefined) { - //if URL changed - if (tabId) { - tabUpdate(tabId); - } - } -}); +//the last video id loaded, to make sure it is a video id change +var sponsorVideoID = null; chrome.runtime.onMessage.addListener(function (request, sender, callback) { if (request.message == "submitTimes") { @@ -164,13 +148,6 @@ function submitTimes(videoID, callback) { }); } -function tabUpdate(tabId) { - //send a message to the content script - chrome.tabs.sendMessage(tabId, { - message: 'update' - }); -} - function getUserID(callback) { if (userID != null) { callback(userID); From 883871123a20b188b9ecc74e1bbee9bb4e889e33 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 19:26:26 +0100 Subject: [PATCH 12/26] Update content.js --- content.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/content.js b/content.js index a21c3164..48613b67 100644 --- a/content.js +++ b/content.js @@ -78,12 +78,11 @@ chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { //get messages from the background script and the popup chrome.runtime.onMessage.addListener(messageListener); +window.addEventListener("hashchange", function(event){ + if(id = getYouTubeVideoID(document.URL)) videoIDChange(id); +}); + function messageListener(request, sender, sendResponse) { - //message from background script - if (request.message == "TabUpdate") { - if(id = getYouTubeVideoID(document.URL)) videoIDChange(id); - } - //messages from popup script if (request.message == "sponsorStart") { sponsorMessageStarted(sendResponse); From 6707d6df8d534799a3a47ebfcbd8f08b05e0c496 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 19:59:15 +0100 Subject: [PATCH 13/26] Added onUpdated back as did not work --- background.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/background.js b/background.js index adafe098..ac174a3e 100644 --- a/background.js +++ b/background.js @@ -4,6 +4,12 @@ var userID = null; //the last video id loaded, to make sure it is a video id change var sponsorVideoID = null; +chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { + chrome.runtime.sendMessage({ + message: "update", + }); +}); + chrome.runtime.onMessage.addListener(function (request, sender, callback) { if (request.message == "submitTimes") { submitTimes(request.videoID, callback); From 1b5d5f8a3a9f1a6ab8021239744b25f8f9d8c14d Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 20:15:23 +0100 Subject: [PATCH 14/26] Added tab update back --- content.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content.js b/content.js index 48613b67..057e8eaf 100644 --- a/content.js +++ b/content.js @@ -84,6 +84,11 @@ window.addEventListener("hashchange", function(event){ function messageListener(request, sender, sendResponse) { //messages from popup script + + if (request.message == "update") { + if(id = getYouTubeVideoID(document.URL)) videoIDChange(id); + } + if (request.message == "sponsorStart") { sponsorMessageStarted(sendResponse); } From 02448307ab407bdfc1b3561a01329179251b9457 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 20:32:18 +0100 Subject: [PATCH 15/26] Update background.js --- background.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index ac174a3e..da9a1d39 100644 --- a/background.js +++ b/background.js @@ -5,9 +5,9 @@ var userID = null; var sponsorVideoID = null; chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { - chrome.runtime.sendMessage({ - message: "update", - }); + chrome.tabs.sendMessage(tabId, { + message: 'update', + }); }); chrome.runtime.onMessage.addListener(function (request, sender, callback) { From 866cc33f0e7c52d996c50eb7684a927f99db5ab0 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 8 Aug 2019 20:33:05 +0100 Subject: [PATCH 16/26] Update content.js --- content.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/content.js b/content.js index 057e8eaf..41ea3f78 100644 --- a/content.js +++ b/content.js @@ -1,6 +1,6 @@ //was sponsor data found when doing SponsorsLookup var sponsorDataFound = false; - +var previousVideoID = null; //the actual sponsorTimes if loaded and UUIDs associated with them var sponsorTimes = null; var UUIDs = null; @@ -77,10 +77,6 @@ chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { //get messages from the background script and the popup chrome.runtime.onMessage.addListener(messageListener); - -window.addEventListener("hashchange", function(event){ - if(id = getYouTubeVideoID(document.URL)) videoIDChange(id); -}); function messageListener(request, sender, sendResponse) { //messages from popup script From 1ab33375ecdac3da9648cebc5e47b6172733ab86 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 13:51:59 +0100 Subject: [PATCH 17/26] Update background.js --- background.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/background.js b/background.js index c08ad16b..9e6f5259 100644 --- a/background.js +++ b/background.js @@ -1,3 +1,6 @@ +//the id of this user, randomly generated once per install +var userID = null; + chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.tabs.sendMessage(tabId, { message: 'update', From 2580577ce0b4251d095fe538ede34876a4c51907 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 11 Aug 2019 12:49:25 -0400 Subject: [PATCH 18/26] Added comments --- content.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content.js b/content.js index 5775abc1..bbfc0e11 100644 --- a/content.js +++ b/content.js @@ -206,6 +206,7 @@ function videoIDChange(id) { previousVideoID = id; }); } else { + //set the previous id now, don't wait for chrome.storage.get previousVideoID = id; } @@ -1190,4 +1191,4 @@ function getYouTubeVideoStartTime(url) { } return startTime; -} \ No newline at end of file +} From 1aab52edbe1453aa667774205d3f50b515ab870a Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 19:27:38 +0100 Subject: [PATCH 19/26] Remove userID --- background.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/background.js b/background.js index 9e6f5259..c08ad16b 100644 --- a/background.js +++ b/background.js @@ -1,6 +1,3 @@ -//the id of this user, randomly generated once per install -var userID = null; - chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.tabs.sendMessage(tabId, { message: 'update', From 60242df3c9af20be766f19926d1ae04736a5c5bb Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 19:29:38 +0100 Subject: [PATCH 20/26] Removed stuff thats in utils.js --- content.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/content.js b/content.js index bbfc0e11..55afecf4 100644 --- a/content.js +++ b/content.js @@ -1169,26 +1169,3 @@ function sendRequestToCustomServer(type, fullAddress, callback) { //submit this request xmlhttp.send(); } - -function getYouTubeVideoID(url) { // Returns with video id else returns false - var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; - var match = url.match(regExp); - var id = new URL(url).searchParams.get("v"); - if (url.includes("/embed/")) { - //it is an embed, don't search for v - id = match[7]; - } - - return (match && match[7].length == 11) ? id : false; -} - -//returns the start time of the video if there was one specified (ex. ?t=5s) -function getYouTubeVideoStartTime(url) { - let searchParams = new URL(url).searchParams; - var startTime = searchParams.get("t"); - if (startTime == null) { - startTime = searchParams.get("time_continue"); - } - - return startTime; -} From c7d03aa4238b3f0499a0c7cc077ef312e5600d22 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 19:32:44 +0100 Subject: [PATCH 21/26] videoID --- popup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/popup.js b/popup.js index 2e2ac15e..27a84b8f 100644 --- a/popup.js +++ b/popup.js @@ -207,7 +207,7 @@ function runThePopup() { }, onTabs); function onTabs(tabs) { - chrome.storage.sync.get(['videoid'], function(result) { + chrome.storage.sync.get(['videoID'], function(result) { loadTabData(tabs, result.videoid); }); } From 28322f19b583b2b51f3e9cff3b14d419528fca28 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 19:36:52 +0100 Subject: [PATCH 22/26] videoID --- content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content.js b/content.js index 55afecf4..e14a5d56 100644 --- a/content.js +++ b/content.js @@ -183,7 +183,7 @@ function videoIDChange(id) { //not a url change if (sponsorVideoID == id) return; - chrome.storage.sync.set({videoid: id}); + chrome.storage.sync.set({videoID: id}); //warn them if they had unsubmitted times if (previousVideoID != null) { From 19a1a5efda556c8ef6d0a187cc17a7ab31c426fe Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 21:20:10 +0100 Subject: [PATCH 23/26] Added alertPrevious message --- background.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index c08ad16b..21a605d7 100644 --- a/background.js +++ b/background.js @@ -29,7 +29,14 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { //this allows the callback to be called later return true; - } + } else if (request.message == "alertPrevious") { + chrome.notifications.create("stillThere" + Math.random(), { + type: "basic", + title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", + message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", + iconUrl: "./icons/LogoSponsorBlocker256px.png" + }); + } }); //add help page on install From f254a99d6f5cf1bfc90864154a6b565cbff0824f Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 11 Aug 2019 21:21:04 +0100 Subject: [PATCH 24/26] notifications --- content.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/content.js b/content.js index e14a5d56..75378e32 100644 --- a/content.js +++ b/content.js @@ -194,12 +194,10 @@ function videoIDChange(id) { if (sponsorTimes != undefined && sponsorTimes.length > 0) { //warn them that they have unsubmitted sponsor times - chrome.notifications.create("stillThere" + Math.random(), { - type: "basic", - title: "Do you want to submit the sponsor times for watch?v=" + previousVideoID + "?", - message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", - iconUrl: "./icons/LogoSponsorBlocker256px.png" - }); + chrome.runtime.sendMessage({ + message: "alertPrevious", + previousVideoID: previousVideoID + }) } //set the previous video id to the currentID From a5d605f53980e3548f37f3729e211a1e16e2b365 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 13:38:27 +0100 Subject: [PATCH 25/26] Removed videoID as now message active tab --- popup.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/popup.js b/popup.js index 27a84b8f..c7fc607c 100644 --- a/popup.js +++ b/popup.js @@ -207,9 +207,11 @@ function runThePopup() { }, onTabs); function onTabs(tabs) { - chrome.storage.sync.get(['videoID'], function(result) { - loadTabData(tabs, result.videoid); - }); + chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) { + if (result.videoID) { + loadTabData(tabs, result.videoid); + } + }); } function loadTabData(tabs, currentVideoID) { From 67c4acbc5ec73c92b259d13fbd53e846ac13cc25 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 13:38:35 +0100 Subject: [PATCH 26/26] Removed videoID as now message active tab --- content.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/content.js b/content.js index 75378e32..c6e0fbdb 100644 --- a/content.js +++ b/content.js @@ -182,8 +182,6 @@ function videoIDChange(id) { //not a url change if (sponsorVideoID == id) return; - - chrome.storage.sync.set({videoID: id}); //warn them if they had unsubmitted times if (previousVideoID != null) {