diff --git a/background.js b/background.js
index a48d703..bf32a72 100644
--- a/background.js
+++ b/background.js
@@ -1,17 +1,27 @@
let backgroundPage = browser.extension.getBackgroundPage();
-
-
+//let tab;
+const pass_data = {urls:"urls",tab:"tab_id"}
readUrl();
//on addon click load extension page
//
function Setup(data)
{
- browser.browserAction.onClicked.addListener(() => {
- let promise = browser.tabs.create({"url": "home.html"});
- // promise.then((value) => run(value),()=> failure(value));
+ let promise;
+ browser.browserAction.onClicked.addListener(() => {
+
+ promise = browser.tabs.create({"url": "home.html"},function(tab){
+
+ browser.runtime.onMessage.addListener(()=>{
+ run(data,tab);
+ console.log("pass tab data to run, in promise");
+ console.log(tab);
+ });
+ });
+
+
});
- browser.runtime.onMessage.addListener(()=>run(data));
+
}
function failure(value)
@@ -19,9 +29,16 @@ function failure(value)
console.log("tabs.create returned a failure");
}
-function run(data)
-{
+async function run(data,tab)
+{
let i2=0;
+ // injectScript(tab);
+ await browser.scripting.executeScript({
+ target:{
+ tabId: tab.id
+ },
+ files:["spawn.js"]
+ });
console.log("bbackground.js: received start signal...");
if(i2 == 0)
{
@@ -63,3 +80,4 @@ function readUrl()
}
+
diff --git a/home.html b/home.html
index 5ed967a..5144dd3 100644
--- a/home.html
+++ b/home.html
@@ -4,4 +4,4 @@