forked from sifue/nyobi-commentviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
32 lines (29 loc) · 1004 Bytes
/
script.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
'use strict'
const moduleURL = chrome.runtime.getURL('modules/helpers/dom.js')
import(moduleURL).then(({ waitForSelector }) => {
Promise.all([
waitForSelector('video'),
waitForSelector('canvas'),
]).then(() => {
const link = document.createElement('link')
link.setAttribute('href', chrome.runtime.getURL('comment-viewer.css'))
link.setAttribute('rel', 'stylesheet')
link.setAttribute('type', 'text/css')
document.head.appendChild(link)
const script = document.createElement('script')
script.setAttribute('src', chrome.runtime.getURL('comment-viewer.js'))
script.setAttribute('type', 'module')
document.body.appendChild(script)
}).catch((error) => {
if (error.name === 'TimeoutError') {
console.log(
'動画またはコメントが見つかりませんでした。コメビュの初期化を中断します。',
error,
)
} else {
console.error(error)
}
})
}).catch((error) => {
console.error(error)
})