-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.js
More file actions
30 lines (26 loc) · 874 Bytes
/
background.js
File metadata and controls
30 lines (26 loc) · 874 Bytes
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
'use strict'
chrome.runtime.onInstalled.addListener(() => {
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
// Aqui podem ser adicionadas condições para que a extenssão seja ativada
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}
])
})
chrome.runtime.onConnect.addListener(port => {
port.onMessage.addListener(msg => {
port.postMessage({ counter: msg.counter + 1 })
})
})
chrome.extension.onRequest.addListener((request, sender, sendResponse) => {
zsendResponse({ counter: request.counter + 1 })
})
chrome.runtime.onMessage.addListener((response, sender, sendResponse) => {
alert(response)
})
})