works until loading page

This commit is contained in:
Jonathan Wyss 2024-03-17 14:40:01 +01:00
parent fee1b77f1c
commit 3a148716b2
4 changed files with 28 additions and 34 deletions

View File

@ -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()

12
home.js
View File

@ -1,13 +1,13 @@
window.onload = run;
function run()
{
document.getElementById("id_run").addEventListener("click", function(e){
//window.onload = run;
//function run()
//{
document.getElementById("id_run").addEventListener("click", function(e){
console.log("triggered!!");
alert("judihudi");
startBackgroundScript();
e.preventDefault();
});
}
});
//}
function startBackgroundScript()

View File

@ -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"

View File

@ -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;
}