I want my extension to only appear in specific website.
Details:
- Let's say I set the url to
example.com/*
- So every time I open
example.com/*
my extension will appear - Otherwise, it should be invisible and not working
How can I achieve that?
My extention function is to run in specific website and highlight some div with saved ids.
My current manifest:
{
"manifest_version": 2,
"name": "Dv Extention",
"description": "Highlight Selected",
"version": "1.0",
"background":{
"scripts":["background.js"],
"persistent": false
},
"page_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "Click Here!"
},
"permissions": [
"activeTab",
"https://ajax.googleapis.com/",
"webNavigation"
],
"content_scripts": [
{
"matches": ["*://example.com/*"],
"js": ["jquery-2.1.3.min.js","main.js"]
}
]
}
background.js
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: {
hostEquals: 'example.com'
}
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});