ai generated solutions to our ai generated problems
This commit is contained in:
@@ -12,6 +12,46 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<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="description"
|
||||
|
||||
@@ -205,6 +205,9 @@ function normalizeThemePreference(value) {
|
||||
}
|
||||
|
||||
function storedThemePreference() {
|
||||
const bootTheme = window.__TSS_BOOT_PREFERENCES__?.theme
|
||||
if (bootTheme) return normalizeThemePreference(bootTheme)
|
||||
|
||||
const cookieValue = readCookie(themePreferenceCookie)
|
||||
if (cookieValue) return normalizeThemePreference(cookieValue)
|
||||
|
||||
@@ -229,6 +232,9 @@ function persistThemePreference(theme) {
|
||||
}
|
||||
|
||||
function storedAnalyticsPreferences() {
|
||||
const bootPreferences = window.__TSS_BOOT_PREFERENCES__?.analyticsPreferences
|
||||
if (bootPreferences) return normalizeAnalyticsPreferences(bootPreferences)
|
||||
|
||||
const cookieValue = readCookie(analyticsPreferencesCookie)
|
||||
if (cookieValue) {
|
||||
try {
|
||||
|
||||
Generated
+1
-1215
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -32,7 +32,6 @@
|
||||
"eslint": "^9.27.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
"globals": "^16.1.0",
|
||||
"rollup-plugin-obfuscator": "^1.1.0"
|
||||
"globals": "^16.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-31
@@ -2,36 +2,6 @@ import path from 'node:path'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
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
|
||||
|
||||
@@ -170,7 +140,7 @@ export default defineConfig(({ mode }) => {
|
||||
return {
|
||||
root: path.resolve(__dirname, 'frontend'),
|
||||
publicDir: path.resolve(__dirname, 'frontend/public'),
|
||||
plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss(), obfuscate()],
|
||||
plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss()],
|
||||
build: {
|
||||
outDir: path.resolve(__dirname, 'dist'),
|
||||
emptyOutDir: true,
|
||||
|
||||
+1
-1
@@ -356,7 +356,7 @@ function validateBuiltDist() {
|
||||
|
||||
const html = fs.readFileSync(indexPath, 'utf8')
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user