forked from potch/reader-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground_script.js
More file actions
37 lines (30 loc) · 778 Bytes
/
Copy pathbackground_script.js
File metadata and controls
37 lines (30 loc) · 778 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
31
32
33
34
35
36
37
const readerTheme = {
"images": {
"headerURL": "/img/bg.svg",
"additional_backgrounds": [ "/img/book.jpg" ]
},
"properties": {
"additional_backgrounds_alignment": [ "top" ],
"additional_backgrounds_tiling": [ "no-repeat" ]
},
"colors": {
"accentcolor": "#432",
"tab_text": "#fff",
"textcolor": "#000",
"toolbar": "rgba(0,0,0,.2)"
}
};
browser.tabs.onActivated.addListener(event => update(event.tabId));
browser.tabs.onUpdated.addListener(tabId => update(tabId));
async function update(tabId) {
let tab = await browser.tabs.get(tabId);
if (!tab.active) {
return;
}
let windowId = tab.windowId;
if (tab.isInReaderMode) {
browser.theme.update(windowId, readerTheme);
} else {
browser.theme.reset();
}
}