I'm writing a Chrome extension that needs to do the following:
So far I have the first one implemented, by calling chrome.tabs.executeScript()
in the popup.html
file and having the following in the manifest to allow the script to run on any page:
"permissions": [
"tabs", "http://*/*"
],
Now, according to http://code.google.com/chrome/extensions/content_scripts.html, if I want a content script to always run on a specific page, I must declare it in the manifest and set permissions to include only pages that the code should run on. However, this will break the first part.
How do I solve this? The only way I can think of is to always call some kind of "caller" script which then does its own checking and loading of other scripts, but that just seems very messy, and i assume there has to be a better way.
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.
Chrome extensions can be either packed or unpacked. Packed extensions are a single file with a . crx extension. Unpacked extensions are a directory containing the extension, including a manifest. json file.
Use multiple 'New Tab' chrome extensions at the same time. MultiNewTab is a chrome extension that enables you to use several 'New Tab' chrome extensions at the same time without having to manually enable and disable them all the time.
{
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"js": ["myscript.js"]
}
],
"permissions": [
"tabs", "http://*/*"
]
}
myscript.js
is automatically injected to google.com, you can still manually inject to http://*/*
.
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