testing
This commit is contained in:
parent
0cc3893be9
commit
68514f7f68
@ -8,33 +8,28 @@ readUrl();
|
||||
function Setup(data)
|
||||
{
|
||||
let i=0;
|
||||
browser.browserAction.onClicked.addListener(() => {
|
||||
browser.browserAction.onClicked.addListener(create);
|
||||
|
||||
}
|
||||
var create = (function(data){
|
||||
let i=0;
|
||||
browser.tabs.create({"url": "home.html"},function(tab){
|
||||
browser.runtime.onMessage.addListener(()=>{
|
||||
nextUrl(data,tab,i);
|
||||
console.log("pass tab data to run, in promise");
|
||||
console.log(tab);
|
||||
browser.runtime.onMessage.addListener((message)=>{
|
||||
if(message === "Button_clicked")
|
||||
{
|
||||
nextUrl(data,tab,i);
|
||||
console.log("pass tab data to run, in promise");
|
||||
console.log(tab);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
function failure(value)
|
||||
{
|
||||
console.log("tabs.create returned a failure");
|
||||
console.log("tabs.create returned a failure");
|
||||
}
|
||||
|
||||
function run(data,tab)
|
||||
{
|
||||
let i2=0;
|
||||
sendMessageToContent(data,tab,i2);
|
||||
// injectScript(tab);
|
||||
//nextUrl()
|
||||
}
|
||||
async function nextUrl(data,tab,i)
|
||||
{
|
||||
let count_urls = data.subscriptions.length;
|
||||
@ -42,13 +37,27 @@ async function nextUrl(data,tab,i)
|
||||
await sendMessageToContent(data,tab,i);
|
||||
code1 = `window.location.replace("${data.subscriptions[i].url}");`
|
||||
console.log(code1);
|
||||
|
||||
await browser.tabs.update(tab.tabid,{url : data.subscriptions[i].url});
|
||||
console.log(tab);
|
||||
console.log("iterating");
|
||||
console.log(i);
|
||||
i++;
|
||||
|
||||
}
|
||||
}
|
||||
function waitforTab(tab,url)
|
||||
{
|
||||
return new Promise(resolve =>{
|
||||
setTimeout(() => {
|
||||
console.log(tab.url);
|
||||
if(tab.url === url){
|
||||
console.log("Resolved wait for tab)");
|
||||
resolve();
|
||||
}
|
||||
},5000);
|
||||
});
|
||||
|
||||
}
|
||||
function sendMessageToContent(data,tab,i)
|
||||
{
|
||||
return new Promise(resolve => {
|
||||
@ -57,24 +66,25 @@ function sendMessageToContent(data,tab,i)
|
||||
file:"spawn.js"
|
||||
})
|
||||
.then(function() {
|
||||
console.log("background.js: received start signal...");
|
||||
if(i == 0)
|
||||
{
|
||||
browser.tabs.sendMessage(tab.id,{state: "Init",url: data.subscriptions[0].url})
|
||||
.then((response) => {
|
||||
console.log("got response!! content should reload");
|
||||
console.log(response);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.tabs.sendMessage(tab.id,{state: i,url: data.subscriptions[i].url})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
console.log("background.js: received start signal...");
|
||||
console.log("backgroundscript received start signal from contentscript");
|
||||
if(i == 0)
|
||||
{
|
||||
browser.tabs.sendMessage(tab.id,{state: "Init",url: data.subscriptions[0].url})
|
||||
.then((response) => {
|
||||
console.log("got response!! content should reload");
|
||||
console.log(response);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.tabs.sendMessage(tab.id,{state: i,url: data.subscriptions[i].url})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version": "1.0",
|
||||
"description": "---",
|
||||
"web_accessible_resources":["newpipe_subscriptions_202403101004.json"],
|
||||
"permissions":["activeTab","<all_urls>"],
|
||||
"permissions":["activeTab","<all_urls>","tabs"],
|
||||
"icons": {
|
||||
"48": "icons/border-48.png"
|
||||
},
|
||||
|
10
spawn.js
10
spawn.js
@ -3,8 +3,14 @@
|
||||
//
|
||||
//
|
||||
|
||||
browser.runtime.onMessage.addListener(worker);
|
||||
// return Promise.resolve(true);
|
||||
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
browser.runtime.sendMessage("Content_Loaded");
|
||||
});
|
||||
|
||||
|
||||
browser.runtime.onMessage.addListener(worker);
|
||||
// return Promise.resolve(true);
|
||||
/*.then(function(){
|
||||
window.location.replace(url);
|
||||
});*/
|
||||
|
Loading…
Reference in New Issue
Block a user