Pass variable from Chrome extension to opened tab

Viewed 1793

In my google chrome extension user clicks on link and than have to be automatically logged in on page.
Flow have to be like this: User click on link in GC Extension, script will take all required params and than send to newly opened tab.
There my script has to insert passed params and make some actions.
But I don't understand, how can I pass variables from GC extension script to newly opened tab?
Here is my manifest.json

"content_security_policy": "script-src 'self' https://ajax.googleapis.com; object-src 'self'",
 "content_scripts": [
    {
    "js": [ "window/content.js"],
    "matches": [
      "https://steamcommunity.com/login/home/?goto=",
      "http://steamcommunity.com/*",
      "https://steamcommunity.com/*"
    ]
   }
 ],
 "background": {
   "scripts": [
     "./scripts/back.js"
    ]
  },
 "web_accessible_resources": [
   "popup.js",
   "window/content.js"
 ],
"permissions": [
    "activeTab",
    "tabs",
    "<all_urls>",
    "cookies",
    "declarativeContent"
 ]


I've tried so far to use this in main.js:

chrome.tabs.executeScript(
   tab1.id,
      {code: "var test =" + test
       allFrames: true
      },
      {file: "../popup.js"}, )
    })

But when click performs, script open new tab, and execute everything I wrote, but don't see variable 'test'.

1 Answers
Related