executeScript is undefined or not a function in a ManifestV3 extension

The executeScript method in ManifestV3 has changed and is now in chrome.scripting API:
https://developer.chrome.com/docs/extensions/reference/scripting/

Add this line in manifest.json:

"permissions": ["scripting"] 

background.js

chrome.scripting.executeScript({
    target: {tabId: id, allFrames: true},
    files: ['content_scripts/cscript.js'],
});

Leave a Comment