How adding more links on the extension page action
Yes, you can register a page action for multiple sites by adding multiple PageStateMatcher
s to the list of conditions
.
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostSuffix: 'example.com' }
}),
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostSuffix: 'example.net' }
}),
],
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}]);
});
});
Note: I replaced urlContains
with hostSuffix
because you wanted to show the page action on certain domains, not on all pages whose URL contain the website's host (e.g. you probably don't want to match http://localhost/path/containing/www.example.com
). See the documentation of the UrlFilter
type for more ways to match pages.