-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.js
41 lines (36 loc) · 914 Bytes
/
content.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
33
34
35
36
37
38
39
40
41
(function () {
chrome.runtime.onMessage.addListener(async function (
message,
sender,
callback
) {
if (message.type !== "notify") {
return;
}
if (!message.hasOwnProperty("config")) {
return;
}
let body = document.querySelector("html body");
let config = message.config;
// alert
if (config.alert) {
alert(config.alert);
}
// style
if (config.style) {
Object.assign(body.style, config.style);
}
// favicon
if (config.favicon) {
document
.querySelectorAll("link[rel=icon]")
.forEach((element) => element.remove());
let favicon;
favicon = document.createElement("link");
favicon.rel = config.favicon.rel;
favicon.type = config.favicon.type;
favicon.href = config.favicon.href;
document.getElementsByTagName("head")[0].appendChild(favicon);
}
});
})();