I'm building my first Chrome extension and was wondering if there's a way for it only to be enabled/displayed on the toolbar when visiting Google Drive?
Reading through the dev guide it looks like I need to either set permissions or content_scripts=>matches in my manifest.json file to something like this:
"permissions" : {"https://drive.google.com/", "http://drive.google.com/"}
or this:
"content_scripts": [
{
"matches": ["https://drive.google.com/", "http://drive.google.com/"],
...
}
Neither seem to be working as my extension shows up on every page I visit. Is there another resource I can take a look at?
"displayed on the toolbar" sounds like you're talking about a page or browser action. Since you only want some pages, this means you want a page action. If you then want to interact with the DOM, then you’ll need a content script. And you’ll want "matches": ["*://drive.google.com/*"]
. The first *
equals the two hosts you listed; the second *
means "any url with that prefix" and may have been your original problem. See match patterns for more details.
If you don’t need a content script, you have the option to use declarativeContent in your event script to show the page action. And "permissions": ["activeTab", "declarativeContent"]
.
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