Reputation: 103
I'm working on a chrome extension and so far my goal is trying to apply the extension to only URLs with "http://www.facebook.com/events/*".
This is my manifest file:
{
"name": "my extension",
"version": "1.0",
"description": "my extension",
"browser_action": {
"default_title": "myextension",
"default_icon": "icon.png"
},
"background_page": "background.html",
"permissions": [
"tabs", "http://www.facebook.com/events/*"
]
}
However, when I try to apply my extension to just "http://www.facebook.com/", the extension continue to run and give out unwanted actions. What do you think is going on? Thank you!
Upvotes: 0
Views: 1211
Reputation: 8910
I am assuming that the background page references some JavaScript (or has JavaScript directly in it) that is still running?
The reason is that the permissions
you have set for is the tabs
, the background page will always load regardless of this permission. If you want to prevent the code on the background page from loading then you need to do something like this:
Either only include the script when the browser action is clicked:
chrome.browserAction.onClicked.addListener(function(tab) {
//do something
});
Or prevent the script from loading only on the pages you want:
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (tab.url.indexOf("//www.facebook.com/events/") > -1) {
// do something
}
});
Upvotes: 1