How to inject script to web page?

Hi Everyone,

I'm new to develop safari extension and faced with the issue that I can't inject script to the web page by my extension.

This is how I trying to do this:

function injectScript(filePath, tag) {

    let script = document.createElement('script');
    script.setAttribute('type', 'text/javascript');
    script.setAttribute('src', filePath);
    document.body.insertBefore(script,
    document.body.firstChild);
}

injectScript(browser.runtime.getURL('inject-script.js'), 'body');

Info.plist

Script is present in source But can't be dowloaded

Please advise me what should I do!

Thanks

Solved

How to inject script to web page?
 
 
Q