| 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) { |
| 72 | + for (const element of mutation.target.getElementsByTagName('math')) { |
| 68 | | - for (const element of mutation.target.getElementsByTagName('math')) { |
| 73 | + element.childNodes.forEach(function (child) { |
| 69 | | - element.childNodes.forEach(function (child) { |
| 74 | + if (child.nodeType === Node.TEXT_NODE) { |
| 70 | | - if (child.nodeType === Node.TEXT_NODE) { |
| 75 | + child.textContent = ''; |
| 71 | | - child.textContent = ''; |
| 76 | + } |
| 72 | | - } |
| 77 | + }); |
| 73 | | - }); |
| 74 | | - } |
| 75 | 78 | } |
| 76 | 79 | } |
| 77 | 80 | }); |