Files
browser-scripts/scripts/ttv-obfuscated-names/obfuscator.ts
T
zomo 6218d6bad1 changed observer callback
update names based on the element from the mutation event rather than checking the chatbox for unchecked messages each mutation
2026-04-19 19:01:01 -05:00

28 lines
736 B
TypeScript

import { NameConfigInstance, ignoreMod } from './options'
import { getRandomName, getStoredUser, setStoredUser } from './storage'
import { ChatMessage } from './util'
export function obfuscator(
chatMessage: ChatMessage
): NameConfigInstance | null {
if (ignoreMod && chatMessage.isMod) {
return null
}
console.log(`[OBFUSCATOR] Updating Username: ${chatMessage.username}`)
chatMessage.username = chatMessage.username.toLowerCase()
// return stored data
const userData = getStoredUser(chatMessage.username)
if (userData !== null) {
return userData
}
// store new data
const newName = getRandomName()
setStoredUser(chatMessage.username, newName)
return newName
}