File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// Depends on theme-shared.js being loaded first
33
44const T = window . ThemeUtils ;
5+
6+ // Redirect HN referrers to ?theme=geocities so the URL reflects the theme
57const isFromHN = document . referrer . includes ( "news.ycombinator.com" ) ;
6- const theme = isFromHN
7- ? "geocities"
8- : localStorage . getItem ( "theme" ) || "system" ;
8+ if ( isFromHN && ! new URLSearchParams ( window . location . search ) . has ( "theme" ) ) {
9+ window . location . search = "?theme=geocities" ;
10+ }
11+
12+ // All valid theme values (standard + hotdog variants + meta themes)
13+ const VALID_THEMES = [
14+ "system" ,
15+ "light" ,
16+ "dark" ,
17+ "oled" ,
18+ "terminal" ,
19+ "gameboy" ,
20+ "halflife" ,
21+ "vaporwave" ,
22+ "synthwave" ,
23+ "hotdog-ketchup" ,
24+ "hotdog-mustard" ,
25+ "shuffle" ,
26+ "chaos" ,
27+ "shifting" ,
28+ "cursed" ,
29+ "geocities" ,
30+ ] ;
31+
32+ function urlTheme ( ) : string | null {
33+ const param = new URLSearchParams ( window . location . search ) . get ( "theme" ) ;
34+ if ( param && VALID_THEMES . includes ( param ) ) {
35+ return param ;
36+ }
37+ return null ;
38+ }
39+
40+ const theme = urlTheme ( ) || localStorage . getItem ( "theme" ) || "system" ;
941let activeTheme = theme ;
1042const themes = "__CHAOS_THEMES__" . split ( "," ) ;
1143
You can’t perform that action at this time.
0 commit comments