I'm injecting my content script from the background page when the user clicks the browser action button, like so:
chrome.browserAction.onClicked.addListener(function (tab) { chrome.tabs.executeScript(null, { file: "content.js" }); });
So how can I access jQuery from inside my content.js
? I don't see a way to inject that simultaneously.
This extension allows you to write, save, and execute javascript into web pages. You can save scripts to be run globally (on any page), on a specific domain, on a specific page, or via a "URL contains" string.
Content scripts are files that run in the context of web pages. By using the standard Document Object Model (DOM), they are able to read details of the web pages the browser visits, make changes to them, and pass information to their parent extension.
What about:
chrome.tabs.executeScript(null, { file: "jquery.js" }, function() { chrome.tabs.executeScript(null, { file: "content.js" }); });
You can download "jquery.js" from here: http://jquery.com/download/
How about adding this to your manifest file
"content_scripts": [ { "js": [ "jquery.js", "contentscript.js" ] } ],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With