ai generated solutions to our ai generated problems

This commit is contained in:
Heidi
2026-06-15 09:16:39 +01:00
parent e36268b556
commit f6afcf599b
6 changed files with 50 additions and 1249 deletions
+40
View File
@@ -12,6 +12,46 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#e82517" /> <meta name="theme-color" content="#e82517" />
<script>
(() => {
const cookies = Object.fromEntries(
document.cookie.split('; ').filter(Boolean).map((item) => {
const separator = item.indexOf('=')
const key = separator === -1 ? item : item.slice(0, separator)
const value = separator === -1 ? '' : item.slice(separator + 1)
try {
return [decodeURIComponent(key), decodeURIComponent(value)]
} catch {
return [key, value]
}
}),
)
let theme = cookies['tssbot_theme']
if (!theme) {
try {
theme = localStorage.getItem('tssbot.theme')
} catch {}
}
theme = theme === 'dark' ? 'dark' : 'light'
let analyticsPreferences = null
const serializedPreferences = cookies['tssbot_analytics_preferences']
try {
analyticsPreferences = JSON.parse(
serializedPreferences || localStorage.getItem('tssbot.analyticsPreferences') || 'null',
)
} catch {}
window.__TSS_BOOT_PREFERENCES__ = { analyticsPreferences, theme }
document.documentElement.dataset.theme = theme
document.documentElement.style.colorScheme = theme
document.querySelector('meta[name="theme-color"]')?.setAttribute(
'content',
theme === 'dark' ? '#101211' : '#e82517',
)
})()
</script>
<meta name="tss-turnstile-session" content="__TURNSTILE_SESSION__" /> <meta name="tss-turnstile-session" content="__TURNSTILE_SESSION__" />
<meta <meta
name="description" name="description"
+6
View File
@@ -205,6 +205,9 @@ function normalizeThemePreference(value) {
} }
function storedThemePreference() { function storedThemePreference() {
const bootTheme = window.__TSS_BOOT_PREFERENCES__?.theme
if (bootTheme) return normalizeThemePreference(bootTheme)
const cookieValue = readCookie(themePreferenceCookie) const cookieValue = readCookie(themePreferenceCookie)
if (cookieValue) return normalizeThemePreference(cookieValue) if (cookieValue) return normalizeThemePreference(cookieValue)
@@ -229,6 +232,9 @@ function persistThemePreference(theme) {
} }
function storedAnalyticsPreferences() { function storedAnalyticsPreferences() {
const bootPreferences = window.__TSS_BOOT_PREFERENCES__?.analyticsPreferences
if (bootPreferences) return normalizeAnalyticsPreferences(bootPreferences)
const cookieValue = readCookie(analyticsPreferencesCookie) const cookieValue = readCookie(analyticsPreferencesCookie)
if (cookieValue) { if (cookieValue) {
try { try {
+1 -1215
View File
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -32,7 +32,6 @@
"eslint": "^9.27.0", "eslint": "^9.27.0",
"eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20", "eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.1.0", "globals": "^16.1.0"
"rollup-plugin-obfuscator": "^1.1.0"
} }
} }
+1 -31
View File
@@ -2,36 +2,6 @@ import path from 'node:path'
import { defineConfig, loadEnv } from 'vite' import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite' import tailwindcss from '@tailwindcss/vite'
import obfuscatorPlugin from 'rollup-plugin-obfuscator'
const OBFUSCATOR_OPTIONS = {
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayEncoding: ['base64'],
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayThreshold: 0.75,
transformObjectKeys: false,
unicodeEscapeSequence: false,
}
function obfuscate() {
const factory = obfuscatorPlugin.default || obfuscatorPlugin
const inner = factory({ global: true, options: OBFUSCATOR_OPTIONS })
return { ...inner, apply: 'build', enforce: 'post' }
}
const MAX_TEAM_NAME_LENGTH = 80 const MAX_TEAM_NAME_LENGTH = 80
@@ -170,7 +140,7 @@ export default defineConfig(({ mode }) => {
return { return {
root: path.resolve(__dirname, 'frontend'), root: path.resolve(__dirname, 'frontend'),
publicDir: path.resolve(__dirname, 'frontend/public'), publicDir: path.resolve(__dirname, 'frontend/public'),
plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss(), obfuscate()], plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss()],
build: { build: {
outDir: path.resolve(__dirname, 'dist'), outDir: path.resolve(__dirname, 'dist'),
emptyOutDir: true, emptyOutDir: true,
+1 -1
View File
@@ -356,7 +356,7 @@ function validateBuiltDist() {
const html = fs.readFileSync(indexPath, 'utf8') const html = fs.readFileSync(indexPath, 'utf8')
if (/\sintegrity=(["'])sha(?:256|384|512)-[^"']+\1/i.test(html)) { if (/\sintegrity=(["'])sha(?:256|384|512)-[^"']+\1/i.test(html)) {
throw new Error('Frontend build contains integrity attributes that may not match the obfuscated assets') throw new Error('Frontend build contains unsupported integrity attributes')
} }
const assetPaths = [...html.matchAll(/(?:src|href)=(["'])\/(assets\/[^"']+)\1/g)] const assetPaths = [...html.matchAll(/(?:src|href)=(["'])\/(assets\/[^"']+)\1/g)]