I have an object WIO on a webpage which i want to access in my chrome extension. I have followed this example and injected my script.js in the page using first method.
I can successfully read WIO object in script.js. But the problem is i can't access it in popup.html.
Any suggestions will be great appreciated.
Here is manifest.json
{
"manifest_version": 2,
"name": "Campaign Analyzer",
"description": "Analyze campaign data",
"version": "0.1",
"icons": { "128": "icon_128.png" },
"browser_action": {
"default_popup": "popup.html"
},
"permissions": ["activeTab", "<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["jquery-3.4.1.min.js", "inject.js"]
}
],
"web_accessible_resources": ["script.js"]
}
inject.js
s.src = chrome.runtime.getURL("script.js");
s.onload = function() {
this.remove();
};
(document.head || document.documentElement).appendChild(s);
script.js
setTimeout(function() {
console.log(WIO.sessionInfo.context);
}, 6000);