diff --git a/bettercf/core/renderer.js b/bettercf/core/renderer.js index 00217e1..b437fc8 100644 --- a/bettercf/core/renderer.js +++ b/bettercf/core/renderer.js @@ -134,10 +134,12 @@ const theme = this._themes.find(t => t.fileName === this._savedThemeFileName); if (theme) { this.applyTheme(theme, false); + document.documentElement.classList.add('bcf-client-theme-selected'); } else { // Stored theme file not found this._savedThemeFileName = null; this._activeThemeFileName = null; + document.documentElement.classList.remove('bcf-client-theme-selected'); } } @@ -235,14 +237,20 @@ } /* ═══ Mutual Exclusivity ═══ */ - /* When a BetterCF client theme is active, hide active checkmark & active indicator on native theme cards */ - html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active .sprite-icon { + /* When a BetterCF client theme is active/selected, hide active checkmark & active indicator on native theme cards when not hovered */ + html.bcf-client-theme-selected .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .sprite-icon, + html.bcf-native-preview-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .sprite-icon, + html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .sprite-icon { opacity: 0 !important; } - html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active .thumb-icon { + html.bcf-client-theme-selected .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .thumb-icon, + html.bcf-native-preview-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .thumb-icon, + html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .thumb-icon { background-color: transparent !important; } - html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active { + html.bcf-client-theme-selected .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover), + html.bcf-native-preview-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover), + html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) { outline: none !important; border-color: transparent !important; box-shadow: none !important; @@ -318,10 +326,13 @@ if (save) { this._savedThemeFileName = theme.fileName; this._isPreviewing = false; + document.documentElement.classList.add('bcf-client-theme-selected'); try { localStorage.setItem('bcf_active_custom_theme', theme.fileName); ipc?.invoke?.('bcf:settings:set', 'activeCustomTheme', theme.fileName); } catch {} + } else if (this._savedThemeFileName) { + document.documentElement.classList.add('bcf-client-theme-selected'); } console.log(`[BetterCF] Applied custom theme: ${theme.name} (${theme.fileName}) [save=${save}]`); @@ -338,10 +349,13 @@ if (save) { this._savedThemeFileName = null; this._isPreviewing = false; + document.documentElement.classList.remove('bcf-client-theme-selected', 'bcf-native-preview-active'); try { localStorage.removeItem('bcf_active_custom_theme'); ipc?.invoke?.('bcf:settings:set', 'activeCustomTheme', null); } catch {} + } else if (!this._savedThemeFileName) { + document.documentElement.classList.remove('bcf-client-theme-selected', 'bcf-native-preview-active'); } console.log(`[BetterCF] Reverted to native theme [save=${save}].`); @@ -365,6 +379,7 @@ } } this.removeTheme(false); + document.documentElement.classList.remove('bcf-client-theme-selected', 'bcf-native-preview-active'); }, suspendForNativePreview() { @@ -375,17 +390,20 @@ this._styleElement.disabled = true; } document.documentElement.classList.remove('bcf-custom-theme-active'); + document.documentElement.classList.add('bcf-native-preview-active'); } }, resumeFromNativePreview() { if (!this._isSuspendedForNative) return; this._isSuspendedForNative = false; + document.documentElement.classList.remove('bcf-native-preview-active'); if (this._savedThemeFileName) { if (this._styleElement) { this._styleElement.disabled = false; } document.documentElement.classList.add('bcf-custom-theme-active'); + document.documentElement.classList.add('bcf-client-theme-selected'); } }, @@ -415,6 +433,7 @@ const nativeThumb = e.target.closest('.theme-thumb:not(.bcf-theme-thumb)'); if (nativeThumb) { ThemeManager._isSuspendedForNative = false; + document.documentElement.classList.remove('bcf-native-preview-active'); if (ThemeManager.getActiveThemeName()) { ThemeManager.removeTheme(true); const grid = document.querySelector('#bcf-custom-themes-grid'); diff --git a/patcher/patch_core.py b/patcher/patch_core.py index 65b3898..88c76f2 100644 --- a/patcher/patch_core.py +++ b/patcher/patch_core.py @@ -559,13 +559,19 @@ owadview, } /* Mutual exclusivity: hide checkmark on native theme cards when a client theme is active */ -html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active .sprite-icon { +html.bcf-client-theme-selected .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .sprite-icon, +html.bcf-native-preview-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .sprite-icon, +html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .sprite-icon { opacity: 0 !important; } -html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active .thumb-icon { +html.bcf-client-theme-selected .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .thumb-icon, +html.bcf-native-preview-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .thumb-icon, +html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) .thumb-icon { background-color: transparent !important; } -html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active { +html.bcf-client-theme-selected .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover), +html.bcf-native-preview-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover), +html.bcf-custom-theme-active .settings-themes-view .theme-thumb:not(.bcf-theme-thumb).is-active:not(:hover) { outline: none !important; border-color: transparent !important; box-shadow: none !important; @@ -594,9 +600,11 @@ html.bcf-custom-theme-active .pixelforge-skin :not(.highlighted-project-containe } """ css_text = desktop_css.read_text(encoding="utf-8") - if "/* ═══ BetterCurseForge Zero-Ad Rules ═══ */" not in css_text: - desktop_css.write_text(css_text + "\n" + css_rules, encoding="utf-8") - log_callback("[+] Injected zero-ad and theme CSS rules into desktop.css") + if "/* ═══ BetterCurseForge Zero-Ad Rules ═══ */" in css_text: + idx = css_text.find("/* ═══ BetterCurseForge Zero-Ad Rules ═══ */") + css_text = css_text[:idx].rstrip() + desktop_css.write_text(css_text + "\n" + css_rules, encoding="utf-8") + log_callback("[+] Injected zero-ad and theme CSS rules into desktop.css") # 3. Copy BetterCF runtime into asar bcf_src = find_bettercf_source()