fixed bug

This commit is contained in:
Vaica committed 2026-01-31 23:01:35 +08:00
1 parent 0714b8eb48
commit d93167a114
4 files changed
+49 -14

No files matched your search

+21 -7
View File
@@ -37,6 +37,19 @@
// 检查 Artalk 实例并尝试获取数据
const checkArtalk = () => {
if (isResolved) return;
// 如果当前页面没有评论区,不要等待 Artalk 初始化,直接返回空
// 这样可以避免在无评论页(如首页)长时间等待超时
const hasCommentSection = document.getElementById('artalk') ||
document.getElementById('Comments') ||
document.querySelector('.atk-comment-wrap');
if (!hasCommentSection) {
// 延迟一点点返回,确保逻辑统一
setTimeout(() => {
tryResolve([], 'no-comment-section');
}, 100);
return;
}
if (window.artalk) {
// 1. 尝试绑定事件 (只绑定一次)
@@ -358,13 +371,14 @@
document.getElementById('Comments') ||
document.querySelector('.atk-comment-wrap');
if (!hasCommentSection) {
// console.log('[Barrage] 当前页面无评论区,隐藏弹幕');
if (barrageInstance) {
barrageInstance.hide();
}
return;
}
// 即使没有评论区,也不要隐藏弹幕,允许 Hitokoto 或上一页的数据继续播放
// if (!hasCommentSection) {
// // console.log('[Barrage] 当前页面无评论区,隐藏弹幕');
// if (barrageInstance) {
// barrageInstance.hide();
// }
// return;
// }
// 1. 获取容器,如果没有则动态创建
let container = document.querySelector('.barrager');