A
A
Alexey Yarkov2017-03-29 22:16:43
JavaScript
Alexey Yarkov, 2017-03-29 22:16:43

Despair post. Why does it happen that the extension script is loaded but not executed?

The script is loaded
c7d3eeee5f0e4611a93d350413dc5f59.png
The content of test.js I include the script like this:
alert( "Test" );

$( '<script/>', {
    src: browser.extension.getURL( 'js/test.js' )
} ).appendTo( $( 'head' ) );

The script is written in manifest.json in web_accessible_resources.
CHADNT?
UPD #1:
I did it like this:
fetch( browser.extension.getURL( 'js/test.js' ), {
        credentials: 'include'
    } )
    .then( response => response.text() )
    .then( ( script ) => {
        $( '<script/>' ).html( script ).appendTo( $( 'head' ) );
    } )
    .catch( console.error );

And everything works. But is it some kind of a fact?
UPD # 2:
I connect styles in the first way - everything works.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question