Skip to content

Commit

Permalink
Rename danmaku observer
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Dec 5, 2024
1 parent 65d37a8 commit 5fa7937
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,12 +824,12 @@ function checkDanmaku(text: string, offset: number) {
}, offset * 1000 - 100);
}

let observer: MutationObserver = null;
let danmakuObserver: MutationObserver = null;
const processedDanmaku = new Set<string>();

function danmakuForSkip() {
if (!Config.config.enableDanmakuSkip || Config.config.disableSkipping) return;
if (observer) return;
if (danmakuObserver) return;

const targetNode = document.querySelector(".bpx-player-row-dm-wrap"); // 选择父节点
const config = { attributes: true, subtree: true }; // 观察属性变化
Expand All @@ -855,12 +855,12 @@ function danmakuForSkip() {
}
}
};
observer = new MutationObserver(callback);
observer.observe(targetNode, config);
danmakuObserver = new MutationObserver(callback);
danmakuObserver.observe(targetNode, config);
addCleanupListener(() => {
if (observer) {
observer.disconnect();
observer = null;
if (danmakuObserver) {
danmakuObserver.disconnect();
danmakuObserver = null;
processedDanmaku.clear();
return;
}
Expand Down

0 comments on commit 5fa7937

Please sign in to comment.