updated logging

This commit is contained in:
zomo
2026-04-19 19:20:25 -05:00
parent 0f5e4b3c4b
commit dc5afe4743
4 changed files with 30 additions and 10 deletions
+9 -4
View File
@@ -10,6 +10,7 @@
// @supportURL https://git.zomo.dev/zomo/browser-scripts/issues // @supportURL https://git.zomo.dev/zomo/browser-scripts/issues
// @homepageURL https://git.zomo.dev/zomo/browser-scripts // @homepageURL https://git.zomo.dev/zomo/browser-scripts
// ==/UserScript== // ==/UserScript==
var DEBUG = true
var ignoreMod = false var ignoreMod = false
var nameImages = { var nameImages = {
personimage1: personimage1:
@@ -141,7 +142,9 @@ function obfuscator(chatMessage) {
if (ignoreMod && chatMessage.isMod) { if (ignoreMod && chatMessage.isMod) {
return null return null
} }
console.log(`[OBFUSCATOR] Updating Username: ${chatMessage.username}`) if (DEBUG) {
console.info(`[OBFUSCATOR] Updating Username: ${chatMessage.username}`)
}
chatMessage.username = chatMessage.username.toLowerCase() chatMessage.username = chatMessage.username.toLowerCase()
const userData = getStoredUser(chatMessage.username) const userData = getStoredUser(chatMessage.username)
if (userData !== null) { if (userData !== null) {
@@ -181,7 +184,7 @@ function loadChatMessage(chatboxMessage) {
) )
const chatboxUser = chatboxMessage.querySelector('.chat-line__username') const chatboxUser = chatboxMessage.querySelector('.chat-line__username')
if (!chatboxUser) { if (!chatboxUser) {
console.error("found message, couldn't find user") console.error("[OBFUSCATOR] found message, couldn't find user")
return return
} }
if (chatboxUser.querySelector('.obf-name')) { if (chatboxUser.querySelector('.obf-name')) {
@@ -191,7 +194,7 @@ function loadChatMessage(chatboxMessage) {
'.chat-author__display-name' '.chat-author__display-name'
) )
if (!chatboxUserInner) { if (!chatboxUserInner) {
console.error("found message, couldn't find userInner") console.error("[OBFUSCATOR] found message, couldn't find userInner")
return return
} }
let isMod = false let isMod = false
@@ -329,7 +332,9 @@ function eachMutationTarget(record, target) {
) || false ) || false
) )
if (chatboxMessage) { if (chatboxMessage) {
console.warn('[OBFUSCATOR] mutated message', chatboxMessage, record) if (DEBUG) {
console.info('[OBFUSCATOR] mutated message', chatboxMessage, record)
}
loadChatMessage(chatboxMessage) loadChatMessage(chatboxMessage)
loadAdditionalUserNames(chatboxMessage) loadAdditionalUserNames(chatboxMessage)
} }
+11 -4
View File
@@ -1,5 +1,10 @@
import { obfuscator } from './obfuscator' import { obfuscator } from './obfuscator'
import { NameConfigInstance, nameImages, usernameExtraSuffix } from './options' import {
DEBUG,
NameConfigInstance,
nameImages,
usernameExtraSuffix,
} from './options'
import { ChatMessage, elementTreeFind, innermostElement } from './util' import { ChatMessage, elementTreeFind, innermostElement } from './util'
function loadChatMessage(chatboxMessage: Element) { function loadChatMessage(chatboxMessage: Element) {
@@ -20,7 +25,7 @@ function loadChatMessage(chatboxMessage: Element) {
'.chat-line__username' '.chat-line__username'
) )
if (!chatboxUser) { if (!chatboxUser) {
console.error("found message, couldn't find user") console.error("[OBFUSCATOR] found message, couldn't find user")
return return
} }
@@ -33,7 +38,7 @@ function loadChatMessage(chatboxMessage: Element) {
'.chat-author__display-name' '.chat-author__display-name'
) )
if (!chatboxUserInner) { if (!chatboxUserInner) {
console.error("found message, couldn't find userInner") console.error("[OBFUSCATOR] found message, couldn't find userInner")
return return
} }
@@ -224,7 +229,9 @@ function eachMutationTarget(record: MutationRecord, target: HTMLElement) {
) || false ) || false
) )
if (chatboxMessage) { if (chatboxMessage) {
console.warn('[OBFUSCATOR] mutated message', chatboxMessage, record) if (DEBUG) {
console.info('[OBFUSCATOR] mutated message', chatboxMessage, record)
}
loadChatMessage(chatboxMessage) loadChatMessage(chatboxMessage)
loadAdditionalUserNames(chatboxMessage) loadAdditionalUserNames(chatboxMessage)
} }
+4 -2
View File
@@ -1,4 +1,4 @@
import { NameConfigInstance, ignoreMod } from './options' import { DEBUG, NameConfigInstance, ignoreMod } from './options'
import { getRandomName, getStoredUser, setStoredUser } from './storage' import { getRandomName, getStoredUser, setStoredUser } from './storage'
import { ChatMessage } from './util' import { ChatMessage } from './util'
@@ -9,7 +9,9 @@ export function obfuscator(
return null return null
} }
console.log(`[OBFUSCATOR] Updating Username: ${chatMessage.username}`) if (DEBUG) {
console.info(`[OBFUSCATOR] Updating Username: ${chatMessage.username}`)
}
chatMessage.username = chatMessage.username.toLowerCase() chatMessage.username = chatMessage.username.toLowerCase()
+6
View File
@@ -1,3 +1,5 @@
// types
/** /**
* @property color specific color, random color option, or random color option from global list * @property color specific color, random color option, or random color option from global list
*/ */
@@ -16,6 +18,10 @@ export interface NameConfigInstance {
export type UsernameExtraSuffix = (nameConfig: NameConfigInstance) => string export type UsernameExtraSuffix = (nameConfig: NameConfigInstance) => string
// options
export const DEBUG = true
export const ignoreMod: boolean = false export const ignoreMod: boolean = false
export const nameImages = { export const nameImages = {