| 56 | 56 | |
| 57 | 57 | const observerConfig = { childList: true, subtree: true }; |
| 58 | 58 | const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed); |
| 59 | +const countTokensShortDebounced = debounce(RA_CountCharTokens, debounce_timeout.short); |
| 60 | +const checkStatusDebounced = debounce(RA_checkOnlineStatus, debounce_timeout.short); |
| 59 | 61 | |
| 60 | 62 | const observer = new MutationObserver(function (mutations) { |
| 61 | 63 | mutations.forEach(function (mutation) { |
| 64 | + if (!(mutation.target instanceof HTMLElement)) { |
| 65 | + return; |
| 66 | + } |
| 62 | 67 | if (mutation.target.classList.contains('online_status_text')) { |
| 63 | 68 | RA_checkOnlineStatuscheckStatusDebounced(); |
| 64 | 69 | } else if (mutation.target.parentNode === SelectedCharacterTab) { |
| 65 | 70 | setTimeoutcountTokensShortDebounced(RA_CountCharTokens, 200); |
| 66 | 71 | } else if (mutation.target.classList.contains('mes_text')) { |
| 67 | | - if (mutation.target instanceof HTMLElement) { |
| 68 | 72 | for (const element of mutation.target.getElementsByTagName('math')) { |
| 69 | 73 | element.childNodes.forEach(function (child) { |
| 70 | 74 | if (child.nodeType === Node.TEXT_NODE) { |