Hello team.
We are working on our extension's migration from MV2 to MV3.
In MV2, we were injecting a script in all related webpages as
```
const scriptString = 'function runAtStart () { console.log('our code...'); }';
const script = document.createElement('script');
script.textContent = `Our code here.....`
(document.body || document.head || document.documentElement).appendChild(script);
```
According to MV3 policy, we can only inject script tags with src attributes.
```
const s = document.createElement('script');
s.setAttribute('src', 'chrome-extension://<id_of_the_extension>/js/payload.js');
document.documentElement.appendChild(s);
```
Also I have tried this via
*chrome.scripting.registerContentScript*
. and now it is shown to the webpage, but unfortunately it is not calling the methods which I have written into it.
```
await chrome.scripting.registerContentScripts([{
matches: ['https://*/*'],
js: ['js/payload.js'],
runAt: 'document_end',
world: 'MAIN',
}], (e) => console.log(e));
```
And in the payload.js file, I have just written
``` console.log("TEST"); ```
In both scenarios, it is adding script tag with src in webpage DOM but not executing it.
Is there anything I am missing.
Below are the screenshots of webpage behaviour.