remove unused test functions

This commit is contained in:
ccppi 2024-03-19 08:16:47 +01:00
parent ac86ac4bd9
commit 291cc91dfa

View File

@ -1,32 +1,19 @@
let backgroundPage = browser.extension.getBackgroundPage(); let backgroundPage = browser.extension.getBackgroundPage();
//let tab;
const pass_data = {data:"urls",tab:"tab_id"}
let data; let data;
//on addon click load extension page
//
let i=0; let i=0;
data = readUrl() data = readUrl()
.then(function(data){ .then(function(data){
browser.browserAction.onClicked.addListener(function(event1){ browser.browserAction.onClicked.addListener(function(event1){
browser.tabs.create({"url": "home.html"},function(tab){ browser.tabs.create({"url": "home.html"},function(tab){
browser.runtime.onMessage.addListener(function(request,sender,sendResponse){ browser.runtime.onMessage.addListener(function(request,sender,sendResponse){
handleMessages(request,sender,sendResponse,tab,data); handleMessages(request,sender,sendResponse,tab,data);
}); });
}); });
}); });
}); });
function handleMessages(message,sender,sendResponse,tab,data){
function handleMessages(message,sender,sendResponse,tab,data){
if(message === "Button_clicked") if(message === "Button_clicked")
{ {
browser.tabs.executeScript(tab.id,{ browser.tabs.executeScript(tab.id,{
@ -64,67 +51,6 @@ function handleMessages(message,sender,sendResponse,tab,data){
} }
} }
/////////////////////
async function nextUrl(data,tab,i)
{
let count_urls = data.subscriptions.length;
for(i=0;i<count_urls;){
await sendMessageToContent(data,tab,i);
code1 = `window.location.replace("${data.subscriptions[i].url}");`
console.log(code1);
console.log(tab);
await browser.tabs.update(tab.id,{url : data.subscriptions[i].url});
await waitforTab(tab,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 => {
browser.tabs.executeScript(tab.id,{
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();
});
}
});
});
}
function readUrl() function readUrl()
{ {
let data; let data;
@ -152,7 +78,6 @@ function readUrl()
resolve(data); resolve(data);
}) })
.catch((error)=> console.error("couldnt fetch data",error)); .catch((error)=> console.error("couldnt fetch data",error));
}); });
} }