From a229b645e302f47509dfb619fe019d33a04fb830 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Tue, 15 Jan 2019 18:29:25 +0000 Subject: [PATCH] Update ContentScript.js --- ContentScript.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ContentScript.js b/ContentScript.js index 571eb9fb..a24e181d 100644 --- a/ContentScript.js +++ b/ContentScript.js @@ -1,11 +1,13 @@ -var v = document.querySelector('video') -video_id = youtube_parser(document.URL); - -if (video_id) { - SponsorsLookup(video_id); -} +chrome.runtime.onMessage.addListener( + function(request, sender, sendResponse) { + if (request.message === 'ytvideo') { + video_id = youtube_parser(document.URL); + SponsorsLookup(video_id); + } +}); function SponsorsLookup(id) { + v = document.querySelector('video') var xmlhttp = new XMLHttpRequest(); xmlhttp.open('GET', 'https://officialnoob.github.io/YTSponsorSkip-Dataset/' + id, true); xmlhttp.onreadystatechange = function () {