I want to create a new tab and modify the DOM inside a Chrome Extension's background.js with manifest V3:
chrome.tabs.create({ url : 'http://example.com'},function(newTab) {
document.body.innerHTML = "Example.com website content modified in tab "+ newTab.id + "!";
}
But why is this not doing anything, and how to fix this?
This below also didn't work:
chrome.tabs.create({ url : 'http://example.com'},function(newTab) {
function myScript(){
document.body.innerHTML = "Example.com website content modified in tab "+ newTab.id + "!";
}
chrome.scripting.executeScript( {
target: {tabId: newTab.id},
function: myScript,
});
}