Skip to content

Commit

Permalink
cooked
Browse files Browse the repository at this point in the history
  • Loading branch information
zheng980 committed Nov 5, 2025
1 parent 26db015 commit df96442
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,40 @@
(function() {
'use strict';

// Apply color mode immediately (before DOM is ready) to prevent flash of unstyled content
// This ensures CSS variables are set before the page renders
function applyColorModeEarly() {
try {
let storedMode = localStorage.getItem("styles")
if (!storedMode || storedMode === "auto") {
// Auto mode - use system preference
let mode = window.matchMedia('(prefers-color-scheme: dark)').matches ? "darkMode" : "lightMode"
// Don't add class yet, let setColorMode handle it properly
colorScheme = mode
} else {
colorScheme = storedMode
// Apply class immediately if not auto
if (storedMode === "darkMode" || storedMode === "lightMode") {
document.documentElement.classList.add(storedMode)
}
}
} catch (e) {
// If localStorage fails, use auto mode
let mode = window.matchMedia('(prefers-color-scheme: dark)').matches ? "darkMode" : "lightMode"
colorScheme = mode
}
}

// Apply color mode as early as possible
applyColorModeEarly()

// Initialize the extension
async function init() {
await changeTitle()
settings("apply")
setCssFilters() // Set CSS filters after settings are applied (matches original userscript order)
parseTicket()
parseOtherElements() // Call parseOtherElements to inject styles into shadow DOMs (matches original)
checkPath()
}

Expand Down
4 changes: 4 additions & 0 deletions content/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,10 @@ box-shadow: 0 8px 16px var(--shadow-1),0 24px 38px var(--shadow-2) !important;
background-color: var(--bg-0) !important;
}

#divHeader {
background-color: var(--col-100) !important;
}

.tdx-right-side-panel__drag-border {
background: linear-gradient(var(--col-400),var(--col-400)) no-repeat left/1px 10% !important;
}
Expand Down

0 comments on commit df96442

Please sign in to comment.