I recently discovered the chrome extension development and got stuck with the runtime.excuteScript method, the callback in 3rd argument systematically returns me an empty object ...
For brevity, I will spare you all of my manifest.json(v2):
▼ manifest permissions:
"permissions": [
"storage",
"cookies",
"tabs",
"background",
"activeTab",
"<all_urls>",
"*://*/*"
]
▼ manifest content-script:
"content_scripts": [
{
"matches": ["<all_urls>"],
"run_at": "document_end",
"js": ["js/content-script.js"]
}
]
My goal is to send the content of the localStorage to my extension.
▼ pop-up.js:
chrome.tabs.executeScript(
null,
{ file: "js/content-script.js" },
(result) => {
if(result) console.log( " Result of content-script:",result )
else console.log(" No content-script, no result")
}
);
▼ content-script.js:
localStorage;
▼ output in the console of extension:
Result of content-script: Array(1)
▶︎ 0: {}
length:1
▶︎ __proto__: Array(0)
Please make this a wonderful evening by explaining the mistake to me! Thank you!