Armando
Armando

Reputation: 217

Chrome extension manifest v3 exclude_glob and exclude_matches not working

I've got 2 scripts that I want to load depending on what site ppl open in browser ...
login.js should only be loaded on admin.someDomain.com, admin.someOtherDomain.com and localhost
dc_ctre_content.js should be loaded on all other pages opened in browser.
Now, login.js is correctly added, but dc_ctre_content.js is also added to admin.someDomain.com, admin.someOtherDomain.com and localhost domains and it shouldn't be!
Since I'm developing locally my local address is "http://localhost:5090/something" maybe that's the problem.
from manifest.json v3:

"content_scripts": [
{
    "matches": ["*://admin.someDomain.com/*","*://admin.someOtherDomain.com/*","*://localhost/*"],
    "js": ["js/login.js"],
    "run_at": "document_end"
},
{
    "exclude_globs": ["*://admin.someDomain.com/*","*://admin.someOtherDomain.com/*","*://localhost/*"],
    "matches": ["https://*/*","http://*/*"],
    "js": ["js/dc_ctre_content.js"],
    "run_at": "document_end"
}
],

I've also tried with exclude_matches but no joy.
Any help appreciated on how to not load dc_ctre_content.js script on excluded domains.

Regards

Upvotes: 0

Views: 1023

Answers (1)

Armando
Armando

Reputation: 217

this fixed it
"exclude_globs": ["http://localhost:*/*"]
I had to put :* after host name for this to work properly.

Upvotes: 1

Related Questions