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