-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
30 lines (29 loc) · 1.03 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
chrome.runtime.onInstalled.addListener(function () {
// Replace all rules ...
chrome.declarativeContent.onPageChanged.removeRules(undefined, function () {
// With a new rule ...
chrome.declarativeContent.onPageChanged.addRules([
{
// That fires when a page's URL contains a 'g' ...
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostContains: "burpple", urlContains: "timeline" },
}),
],
// And shows the extension's page action.
actions: [new chrome.declarativeContent.ShowPageAction()],
},
]);
});
});
chrome.runtime.onMessage.addListener((msg, sender) => {
// First, validate the message's structure.
if (msg.from === "content" && msg.subject === "init") {
// Enable the page-action for the requesting tab.
console.log("content script initialised");
}
if (msg.from === "content" && msg.subject === "viewMore") {
// Enable the page-action for the requesting tab.
console.log("view more");
}
});