You've already forked bilibili-subtitle
延迟插入iframe(插入太快,网络较差时容易出现b站网页刷新,原因暂时未知,可能b站的某种机制?)
This commit is contained in:
@@ -6,12 +6,13 @@ const getVideoElement = () => {
|
||||
return videoWrapper.querySelector('video')
|
||||
}
|
||||
|
||||
let danmukuBox = null
|
||||
const timerIframe = setInterval(function () {
|
||||
if (danmukuBox) return clearInterval(timerIframe)
|
||||
|
||||
danmukuBox = document.getElementById('danmukuBox')
|
||||
var danmukuBox = document.getElementById('danmukuBox')
|
||||
if (danmukuBox) {
|
||||
clearInterval(timerIframe)
|
||||
|
||||
//延迟插入iframe(插入太快,网络较差时容易出现b站网页刷新,原因暂时未知,可能b站的某种机制?)
|
||||
setTimeout(() => {
|
||||
var vKey = ''
|
||||
for (const key in danmukuBox?.dataset) {
|
||||
if (key.startsWith('v-')) {
|
||||
@@ -30,6 +31,9 @@ const timerIframe = setInterval(function () {
|
||||
}
|
||||
//insert before first child
|
||||
danmukuBox?.insertBefore(iframe, danmukuBox?.firstChild)
|
||||
|
||||
console.debug('iframe inserted')
|
||||
}, 1500)
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
|
Reference in New Issue
Block a user