FIX: loading extension after chat popout and url change

WIP: Transforming to TypeScript
This commit is contained in:
2022-09-13 22:59:41 +03:00
parent 9bfc81d98a
commit 7e667fd9e4
17 changed files with 8342 additions and 1109 deletions

35
src/index.ts Normal file
View File

@@ -0,0 +1,35 @@
import './styles/main.scss';
import TwitchNote from "./TwitchNote";
const ChatContainerClass = 'chat-scrollable-area__message-container';
const twitchNote = new TwitchNote();
let chatExists = false;
let lastUrl = '';
function init() {
// check for chat container existence
setInterval(() => {
// check for URL changes (going through different channels)
const currentUrl = window.location.href;
if (lastUrl !== currentUrl) {
lastUrl = currentUrl;
chatExists = false;
return;
}
// check for chat container appearing in DOM
const targetNode = document.querySelector(`.${ChatContainerClass}`);
if (targetNode) {
if (!chatExists) {
// chat container appeared
twitchNote.init(targetNode);
}
chatExists = true;
} else {
chatExists = false;
}
}, 1000);
}
init();