for some reason my executeScript function is not working. This is my code:
async function scrape_get_url(){ console.log("Getting url: " + from_url); var tab_id; chrome.tabs.create({ "url": from_url}, function(newTab){ tab_id = newTab.id; console.log("Checking for tab url update"); }); chrome.tabs.onUpdated.addListener( function(tabId, info) { if(tabId == tab_id && info.url){ console.log("Executing scrape script"); console.log("tab id:" + tab_id); console.log("updated tab url:" + info.url); chrome.scripting.executeScript({ target: {tabId: tab_id}, function: scrape }); } }); } function scrape(){ console.log("Getting Element..."); } This is my output:
Getting url: https://developer.chrome.com/docs/extensions/mv3/getstarted Checking for tab url update Executing scrape script tab id:293 updated tab url:https://developer.chrome.com/docs/extensions/mv3/getstarted/ I have an onUpdated listener due to a chrome bug, as stated here. Also, the reason I put the onUpdated function outside of the create function's callback, is because according to another question on StackOverflow(that I can't find anymore :/ ), putting the executeScript within the create's callback will not run the script.
My permissions are set correctly in the manifest file.