forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
21 lines (19 loc) · 855 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Create a rule that will show the page action when the conditions are met.
const kMatchRule = {
// Declare the rule conditions.
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'developer.chrome.com'},
})],
// Shows the page action when the condition is met.
actions: [new chrome.declarativeContent.ShowPageAction()]
}
// Register the runtime.onInstalled event listener.
chrome.runtime.onInstalled.addListener(function() {
// Overrride the rules to replace them with kMatchRule.
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([kMatchRule]);
});
});