Files
browser-scripts/scripts/ttv-obfuscated-names/obfuscator.ts
T
2026-04-19 20:11:00 -05:00

30 lines
771 B
TypeScript

import { DEBUG, NameConfigInstance, ignoreMod } from './options'
import { getRandomName, getStoredUser, setStoredUser } from './storage'
import { NameDetails } from './util'
export function obfuscator(
chatMessage: NameDetails
): NameConfigInstance | null {
if (ignoreMod && chatMessage.isMod) {
return null
}
if (DEBUG) {
console.info(`[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
}