ai generated solutions to our ai generated problems
This commit is contained in:
+41
-1
@@ -42,11 +42,51 @@
|
|||||||
document.documentElement.dataset.theme = theme
|
document.documentElement.dataset.theme = theme
|
||||||
document.documentElement.style.backgroundColor = bg
|
document.documentElement.style.backgroundColor = bg
|
||||||
document.documentElement.style.colorScheme = theme
|
document.documentElement.style.colorScheme = theme
|
||||||
|
|
||||||
|
const customColor = cookies['tssbot_custom_color'] || localStorage.getItem('tssbot.customColor')
|
||||||
|
if (customColor && /^#[0-9a-fA-F]{6}$/.test(customColor)) {
|
||||||
|
document.documentElement.style.setProperty('--color-fury-cyan', customColor)
|
||||||
|
document.documentElement.style.setProperty('--color-ring', customColor)
|
||||||
|
|
||||||
|
const bigint = parseInt(customColor.replace('#', ''), 16)
|
||||||
|
const r = (bigint >> 16) & 255
|
||||||
|
const g = (bigint >> 8) & 255
|
||||||
|
const b = bigint & 255
|
||||||
|
document.documentElement.style.setProperty('--color-shadow', 'rgba(' + r + ', ' + g + ', ' + b + ', ' + (theme === 'dark' ? '0.18' : '0.12') + ')')
|
||||||
|
|
||||||
|
const adjust = (val, percent) => percent > 0
|
||||||
|
? Math.max(0, Math.min(255, Math.round(val + (255 - val) * percent)))
|
||||||
|
: Math.max(0, Math.min(255, Math.round(val * (1 + percent))))
|
||||||
|
const formatHex = (nr, ng, nb) => '#' + ((1 << 24) + (nr << 16) + (ng << 8) + nb).toString(16).slice(1)
|
||||||
|
|
||||||
|
const aquaColor = formatHex(adjust(r, 0.2), adjust(g, 0.2), adjust(b, 0.2))
|
||||||
|
const violetColor = formatHex(adjust(r, -0.2), adjust(g, -0.2), adjust(b, -0.2))
|
||||||
|
|
||||||
|
document.documentElement.style.setProperty('--color-fury-aqua', aquaColor)
|
||||||
|
document.documentElement.style.setProperty('--color-fury-violet', violetColor)
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelector('meta[name="theme-color"]')?.setAttribute(
|
document.querySelector('meta[name="theme-color"]')?.setAttribute(
|
||||||
'content',
|
'content',
|
||||||
theme === 'dark' ? '#101211' : '#e82517',
|
customColor && /^#[0-9a-fA-F]{6}$/.test(customColor)
|
||||||
|
? customColor
|
||||||
|
: (theme === 'dark' ? '#101211' : '#e82517')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const rawColors = cookies['tssbot_custom_colors'] || localStorage.getItem('tssbot.customColors')
|
||||||
|
if (rawColors) {
|
||||||
|
const colors = JSON.parse(rawColors)
|
||||||
|
const cssVarMap = { bg: '--color-bg', surface: '--color-surface', text: '--color-text', border: '--color-border', textSoft: '--color-text-soft', textMuted: '--color-text-muted' }
|
||||||
|
for (const [field, cssVar] of Object.entries(cssVarMap)) {
|
||||||
|
if (colors[field] && /^#[0-9a-fA-F]{6}$/.test(colors[field])) {
|
||||||
|
document.documentElement.style.setProperty(cssVar, colors[field])
|
||||||
|
if (field === 'bg') document.documentElement.style.backgroundColor = colors[field]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
let analyticsPreferences = null
|
let analyticsPreferences = null
|
||||||
const serializedPreferences = cookies['tssbot_analytics_preferences']
|
const serializedPreferences = cookies['tssbot_analytics_preferences']
|
||||||
try {
|
try {
|
||||||
|
|||||||
+823
-218
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user