-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (28 loc) · 787 Bytes
/
main.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
31
32
const store = browser.storage.local
let backend = browser.runtime.connect({name:window.location.href})
backend.onMessage.addListener(async function(message) {
const {msg, payload} = JSON.parse(message)
if(msg === "notification") {
createNotification(payload.type, payload.text, payload.fadeOut)
}
if(msg === "marshal") {
const response = {}
const settings = await store.get()
const {sendUrl, sendContents} = settings
if(sendUrl) response.url = window.location.href
if(sendContents) {
const body =
'<head>' +
document.getElementsByTagName('head')[0].innerHTML +
'</head>' +
'<body>' +
document.body.innerHTML +
'</body>';
response.contents = body
}
backend.postMessage(JSON.stringify({
msg: "send",
payload: response,
}));
}
});