works until loading page
This commit is contained in:
parent
fee1b77f1c
commit
3a148716b2
@ -29,26 +29,25 @@ function failure(value)
|
||||
console.log("tabs.create returned a failure");
|
||||
}
|
||||
|
||||
async function run(data,tab)
|
||||
function run(data,tab)
|
||||
{
|
||||
let i2=0;
|
||||
// injectScript(tab);
|
||||
await browser.scripting.executeScript({
|
||||
target:{
|
||||
tabId: tab.id
|
||||
},
|
||||
files:["spawn.js"]
|
||||
let promise = browser.tabs.executeScript(tab.id,{
|
||||
file:"spawn.js"
|
||||
});
|
||||
promise.then(function() {
|
||||
console.log("bbackground.js: received start signal...");
|
||||
if(i2 == 0)
|
||||
{
|
||||
browser.runtime.sendMessage({state: "Init",url: data.subscriptions[0].url});
|
||||
browser.tabs.sendMessage(tab.id,{state: "Init",url: data.subscriptions[0].url});
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.runtime.sendMessage({state: i2,url: data.subscriptions[i2].url});
|
||||
browser.tabs.sendMessage(tab.id,{state: i2,url: data.subscriptions[i2].url});
|
||||
}
|
||||
i2++;
|
||||
});
|
||||
}
|
||||
|
||||
function readUrl()
|
||||
|
8
home.js
8
home.js
@ -1,13 +1,13 @@
|
||||
window.onload = run;
|
||||
function run()
|
||||
{
|
||||
//window.onload = run;
|
||||
//function run()
|
||||
//{
|
||||
document.getElementById("id_run").addEventListener("click", function(e){
|
||||
console.log("triggered!!");
|
||||
alert("judihudi");
|
||||
startBackgroundScript();
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
function startBackgroundScript()
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version": "1.0",
|
||||
"description": "---",
|
||||
"web_accessible_resources":["newpipe_subscriptions_202403101004.json"],
|
||||
"permissions":["tabs","scripting"],
|
||||
"permissions":["activeTab","<all_urls>"],
|
||||
"icons": {
|
||||
"48": "icons/border-48.png"
|
||||
},
|
||||
@ -21,7 +21,7 @@
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"*://youtube.com/*"
|
||||
"<all_urls>"
|
||||
],
|
||||
"js": [
|
||||
"spawn.js"
|
||||
|
7
spawn.js
7
spawn.js
@ -2,7 +2,7 @@
|
||||
//1.grant host permission
|
||||
//
|
||||
//
|
||||
browser.runtime.onMessage.addListener(() =>
|
||||
browser.runtime.onMessage.addListener((message) =>
|
||||
{
|
||||
console.log("inside handler");
|
||||
if(message.state != "Init")//on init only load page
|
||||
@ -16,8 +16,3 @@ console.log("inside handler");
|
||||
|
||||
});
|
||||
|
||||
//if(number>0)
|
||||
function handle(message)
|
||||
{
|
||||
// window.location = url;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user