-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathloader.js
More file actions
41 lines (32 loc) · 1.32 KB
/
loader.js
File metadata and controls
41 lines (32 loc) · 1.32 KB
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
async function load() {
const res = await fetch(chrome.runtime.getURL('cs.js'), { method: 'GET' })
const js = await res.text()
const script = document.createElement('script')
script.textContent = js
document.body.insertBefore(script, document.body.firstChild)
// --- tfjs ---
const res_tf = await fetch('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.2', { method: 'GET' })
const js_tf = await res_tf.text();
const script_tf = document.createElement('script');
script_tf.textContent = js_tf;
// --- bodypix ---
const script_bp = document.createElement('script');
script_bp.src = 'https://cdn.jsdelivr.net/npm/@tensorflow-models/body-pix@2.0';
document.body.insertBefore(script_bp, document.body.firstChild);
document.body.insertBefore(script_tf, document.body.firstChild);
}
const _PRINT_LOADER_LOG = false;
function _loaderlog(var_args) {
if (_PRINT_LOADER_LOG) {
console.log(...arguments);
}
}
// window.addEventListener('load', (evt) => {
// _loaderlog('event load'); // 元のindex.html の中の処理より後に呼ばれる
// load()
// }, false)
window.addEventListener('load', async (evt) => {
_loaderlog('event load'); // 元のindex.html の中の処理より後に呼ばれる
await load()
}, true) // use capture
_loaderlog('loader.js');