diff --git a/manifest.json b/manifest.json index 48293e8..5a48a92 100644 --- a/manifest.json +++ b/manifest.json @@ -17,6 +17,16 @@ "background":{ "scripts": ["background.js"] }, - "host_permissions":["*://youtube.com/*"] + "host_permissions":["*://youtube.com/*"], + "content_scripts": [ + { + "matches": [ + "*://youtube.com/*" + ], + "js": [ + "spawn.js" + ] + } + ] } diff --git a/spawn.js b/spawn.js index 263df83..fc3beb8 100644 --- a/spawn.js +++ b/spawn.js @@ -2,15 +2,9 @@ //1.grant host permission // // -browser.runtime.onMessage.addListener(function (message,listener) +browser.runtime.onMessage.addListener(() => { - handle(message); -}); - -//if(number>0) -function handle(message) - { - console.log("inside handler"); +console.log("inside handler"); if(message.state != "Init")//on init only load page { document.getElementsByClassName("yt-spec-button-shape-next yt-spec-button-shape-next--filled yt-spec-button-shape-next--mono yt-spec-button-shape-next--size-m")[0].click(); @@ -19,5 +13,11 @@ function handle(message) let url = message.url; console.log(url); window.location.replace(url); - // window.location = url; + +}); + +//if(number>0) +function handle(message) + { + // window.location = url; }