You've already forked bilibili-subtitle
refactor: 必要时取消定时器,提高性能
This commit is contained in:
@@ -6,14 +6,12 @@ const getVideoElement = () => {
|
||||
return videoWrapper.querySelector('video')
|
||||
}
|
||||
|
||||
var danmukuBoxLoaded = false
|
||||
setInterval(function () {
|
||||
if (danmukuBoxLoaded) return
|
||||
let danmukuBox = null
|
||||
const timerIframe = setInterval(function () {
|
||||
if (danmukuBox) return clearInterval(timerIframe)
|
||||
|
||||
var danmukuBox = document.getElementById('danmukuBox')
|
||||
danmukuBox = document.getElementById('danmukuBox')
|
||||
if (danmukuBox) {
|
||||
danmukuBoxLoaded = true
|
||||
setTimeout(function () {
|
||||
var vKey = ''
|
||||
for (const key in danmukuBox?.dataset) {
|
||||
if (key.startsWith('v-')) {
|
||||
@@ -32,7 +30,6 @@ setInterval(function () {
|
||||
}
|
||||
//insert before first child
|
||||
danmukuBox?.insertBefore(iframe, danmukuBox?.firstChild)
|
||||
}, 1500)
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
|
Reference in New Issue
Block a user