Skip to content

Commit 434870c

Browse files
authored
Add files via upload
1 parent cef99fc commit 434870c

2 files changed

Lines changed: 4240 additions & 0 deletions

File tree

js/background.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
let creating;
2+
const setupOffscreenDocument = async function(path) {
3+
if (await chrome.offscreen.hasDocument?.()) return;
4+
5+
if (creating) {
6+
await creating;
7+
} else {
8+
creating = chrome.offscreen.createDocument({
9+
url: chrome.runtime.getURL(path),
10+
reasons: [
11+
chrome.offscreen.Reason.WORKERS,
12+
chrome.offscreen.Reason.LOCAL_STORAGE
13+
],
14+
justification: "So that the SQLite tables are created before the first display, allowing the page to load faster.",
15+
});
16+
await creating;
17+
creating = null;
18+
}
19+
}
20+
21+
setupOffscreenDocument("index.html");
22+
23+
chrome.action.onClicked.addListener((_) => {
24+
chrome.tabs.create({
25+
url: "index.html"
26+
});
27+
});

0 commit comments

Comments
 (0)