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