I am getting confused with Chrome Extension devtools_page. I want to send a command to the current websites Namespace and retrieve information from that page.
devtools_page JS file
//hey webpage, I know you have the Namespace ABC with the method collectData
webpage
let data = ABC.collectData;
return data;
devtools
// I got the data
Where do I add the communication in the extension to be able to get these data. In the manifest I have "content_scripts" with "document_start" And I have "web_accessible-resource" and the JS file from the "devtools_page".
And how do I instantiate the communication?
I tried so many different things and did not manage to get the communication up and running.
My best try was to use chrome.tabs.executeScript, but I cannot access the Namespace.
This is what I have so far:
a) executeScript
chrome.tabs.executeScript({
code: 'console.log("foo"); return true;
}, function(results) {
console.log(results[0]);
});
Result: Unchecked runtime.lastError: Cannot access contents of url "devtools://devtools/bundled/devtools_app.html?remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/@326d148b9655369b86498d9ecca39f63dd2bdd2d/&can_dock=true&dockSide=undocked". Extension manifest must request permission to access this host.
b) devtools.inspectedWindow.eval
chrome.devtools.inspectedWindow.eval(
"ABC.AllItems.all",
function(result, isException) {
if (isException)
//==> I am getting here
}
);
Result: Object reference chain is too long
Any help is appreciated.