I am struggling to get this simple f-ty working... My scenario is:
- get current URL
- modify it
- navigate/redirect to it
- execute custom JS code there
The most problems I have is with 4)
manifest.json
{ "name": "Hello, World!", "description": "Navigate and execute custom js script", "version": "1.0", "manifest_version": 3, "permissions": [ "tabs", "activeTab", "scripting" ], "background": { "service_worker": "background.js" }, "action": {} } background.js
function myCustomScript() { alert('myCustomScript test ok!'); console.log('myCustomScript test ok!'); } chrome.action.onClicked.addListener((tab) => { chrome.tabs.update({url: "https://example.com"}, myCustomScript); }); The page got redirected but my js function is not executed! Do you know why and how to fix it?
P.S: this is my first time I am creating my chrome extension, maybe I am doing something wrong...