quadroman
quadroman

Reputation: 11

extension $ is not defined manifest v3

now script js add from background.js

chrome.scripting.executeScript({
            target: {tabId: tabID, allFrames: true},
            files: ['script.js']
})

script.js

var jsURL = chrome.runtime.getURL("jquery/jquery.min.js");

var jq = document.createElement('script');

jq.src = jsURL;

document.head.prepend(jq);


window.onload = function(){
    var t = setTimeout(function(){
       $.noConflict(true);
       $("p").append(" <b>Appended text</b>.");
    }, 5000);
}

manifest v3

"web_accessible_resources": [{
        "resources": ["jquery/jquery.min.js", "css/style.css" ],
        "matches": ["<all_urls>"],
        "extension_ids": []
    }],

Uncaught ReferenceError: $ is not defined

how inject jquery in manifest 3 ?

Upvotes: 0

Views: 805

Answers (1)

吉田裕範
吉田裕範

Reputation: 21

How about this.

popup.html

<script src="jquery/jquery.min.js"/>
<script src="script.js"/>

Upvotes: 1

Related Questions