This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
init.js
35 lines (30 loc) · 1.15 KB
/
init.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
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
(async () => {
const site = location.host.endsWith('.notion.site'),
page = location.pathname.split(/[/-]/g).reverse()[0].length === 32,
whitelisted = ['/', '/onboarding'].includes(location.pathname),
signedIn = localStorage['LRU:KeyValueStore2:current-user-id'];
if (site || page || (whitelisted && signedIn)) {
const api = await import(chrome.runtime.getURL('api/index.mjs')),
{ fs, registry, web } = api;
for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
for (const sheet of mod.css?.client || []) {
web.loadStylesheet(`repo/${mod._dir}/${sheet}`);
}
for (let script of mod.js?.client || []) {
script = await import(fs.localPath(`repo/${mod._dir}/${script}`));
script.default(api, await registry.db(mod.id));
}
}
const errors = await registry.errors();
if (errors.length) {
console.log('[notion-enhancer] registry errors:');
console.table(errors);
}
}
})();