From 2a42c3e715622e664bd4cd6872bb80a5c49d80e7 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Fri, 26 Dec 2025 21:36:01 +0100 Subject: [PATCH] More or less finish rework of how setting defaults work --- src/common/enums/AspectRatioType.enum.ts | 1 + ...eddedContentSettingsOverridePolicy.enum.ts | 3 +- .../SiteExtensionSettings.vue | 597 ------------------ src/ext/conf/ExtConfPatches.ts | 2 +- src/ext/conf/ExtensionConf.ts | 61 +- src/ui/components/SettingsWindowContent.vue | 55 +- .../segments/ChangelogContent.vue | 6 +- .../Panels/FrameSiteSettings.vue | 14 +- .../Panels/OtherSiteSettings.vue | 25 - .../Panels/SiteExtensionSettings.vue | 152 +++-- 10 files changed, 201 insertions(+), 715 deletions(-) delete mode 100644 src/csui/src/PlayerUiPanels/PanelComponents/ExtensionSettings/SiteExtensionSettings.vue diff --git a/src/common/enums/AspectRatioType.enum.ts b/src/common/enums/AspectRatioType.enum.ts index 586030f..18c3a2d 100644 --- a/src/common/enums/AspectRatioType.enum.ts +++ b/src/common/enums/AspectRatioType.enum.ts @@ -1,4 +1,5 @@ enum AspectRatioType { + Default = -3, // inherit from global settings Cycle = -2, Initial = -1, // page default Reset = 0, // reset to initial diff --git a/src/common/enums/EmbeddedContentSettingsOverridePolicy.enum.ts b/src/common/enums/EmbeddedContentSettingsOverridePolicy.enum.ts index db027d4..9c90a81 100644 --- a/src/common/enums/EmbeddedContentSettingsOverridePolicy.enum.ts +++ b/src/common/enums/EmbeddedContentSettingsOverridePolicy.enum.ts @@ -1,7 +1,8 @@ enum EmbeddedContentSettingsOverridePolicy { Always = 2, UseAsDefault = 1, - Never = 0, + Default = 0, + Never = -1, } export default EmbeddedContentSettingsOverridePolicy; diff --git a/src/csui/src/PlayerUiPanels/PanelComponents/ExtensionSettings/SiteExtensionSettings.vue b/src/csui/src/PlayerUiPanels/PanelComponents/ExtensionSettings/SiteExtensionSettings.vue deleted file mode 100644 index 80ce99e..0000000 --- a/src/csui/src/PlayerUiPanels/PanelComponents/ExtensionSettings/SiteExtensionSettings.vue +++ /dev/null @@ -1,597 +0,0 @@ - - - - - - - - diff --git a/src/ext/conf/ExtConfPatches.ts b/src/ext/conf/ExtConfPatches.ts index 4d6e48d..a5ebf1e 100644 --- a/src/ext/conf/ExtConfPatches.ts +++ b/src/ext/conf/ExtConfPatches.ts @@ -248,7 +248,7 @@ const ExtensionConfPatch = Object.freeze([ // applyToEmbeddedContent is now an enum, and also no longer optional for (const site in userOptions.sites) { if (userOptions.sites[site].applyToEmbeddedContent === undefined) { - userOptions.sites[site].applyToEmbeddedContent = EmbeddedContentSettingsOverridePolicy.Always; + userOptions.sites[site].applyToEmbeddedContent = EmbeddedContentSettingsOverridePolicy.UseAsDefault; } else { userOptions.sites[site].applyToEmbeddedContent = userOptions.sites[site].applyToEmbeddedContent ? EmbeddedContentSettingsOverridePolicy.Always : EmbeddedContentSettingsOverridePolicy.Never; } diff --git a/src/ext/conf/ExtensionConf.ts b/src/ext/conf/ExtensionConf.ts index a1463fb..5aa60e2 100644 --- a/src/ext/conf/ExtensionConf.ts +++ b/src/ext/conf/ExtensionConf.ts @@ -803,11 +803,15 @@ const ExtensionConf: SettingsInterface = { // #g — only available in @global // #s — only available for specific site enable: ExtensionMode.Disabled, - enableAard: ExtensionMode.Disabled, - enableKeyboard: ExtensionMode.Disabled, + enableAard: ExtensionMode.Theater, + enableKeyboard: ExtensionMode.All, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, + overrideWhenEmbedded: EmbeddedContentSettingsOverridePolicy.Never, // Usually, less-than-legitimate websites embed content from different domains. + // Setting this to 'always' would ensure embedded content always uses extension's + // default settings. It is presumed most people are too dumb to visit "for embedded sizes" + // part of the popup, and those who aren't will prolly find that annoying. defaultType: SiteSupportLevel.Unknown, persistCSA: CropModePersistence.Disabled, @@ -839,10 +843,10 @@ const ExtensionConf: SettingsInterface = { enable: ExtensionMode.All, enableAard: ExtensionMode.All, enableKeyboard: ExtensionMode.All, - enableUI: ExtensionMode.All, + enableUI: ExtensionMode.Default, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, - overrideWhenEmbedded: true, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, + overrideWhenEmbedded: EmbeddedContentSettingsOverridePolicy.Always, override: false, // ignore value localStorage in favour of this type: SiteSupportLevel.OfficialSupport, // is officially supported? (Alternatives are 'community' and 'user-defined') defaultType: SiteSupportLevel.OfficialSupport, // if user mucks around with settings, type changes to 'user-defined'. @@ -867,8 +871,8 @@ const ExtensionConf: SettingsInterface = { enableKeyboard: ExtensionMode.All, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, - overrideWhenEmbedded: true, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, + overrideWhenEmbedded: EmbeddedContentSettingsOverridePolicy.Always, override: false, // ignore value localStorage in favour of this type: SiteSupportLevel.OfficialSupport, // is officially supported? (Alternatives are 'community' and 'user-defined') @@ -893,7 +897,7 @@ const ExtensionConf: SettingsInterface = { enableAard: ExtensionMode.Disabled, enableKeyboard: ExtensionMode.All, enableUI: ExtensionMode.All, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, override: false, type: SiteSupportLevel.CommunitySupport, defaultType: SiteSupportLevel.CommunitySupport, @@ -904,7 +908,7 @@ const ExtensionConf: SettingsInterface = { enableKeyboard: ExtensionMode.All, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, type: SiteSupportLevel.CommunitySupport, defaultType: SiteSupportLevel.CommunitySupport, activeDOMConfig: 'community-mstefan99', @@ -931,9 +935,23 @@ const ExtensionConf: SettingsInterface = { enableKeyboard: ExtensionMode.All, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, type: SiteSupportLevel.OfficialSupport, defaultType: SiteSupportLevel.OfficialSupport, + + activeDOMConfig: 'official', + DOMConfig: { + 'official': { + type: SiteSupportLevel.OfficialSupport, + elements: { + player: { + playerDetectionMode: PlayerDetectionMode.QuerySelectors, + allowAutoFallback: true, + querySelectors: "#movie_player, #player, #c4-player", + } + } + } + } }, "old.reddit.com" : { enable: ExtensionMode.Disabled, @@ -944,19 +962,6 @@ const ExtensionConf: SettingsInterface = { applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never, type: SiteSupportLevel.OfficialBlacklist, defaultType: SiteSupportLevel.OfficialBlacklist, - activeDOMConfig: 'official', - DOMConfig: { - 'official': { - type: SiteSupportLevel.OfficialSupport, - // customCss: 'video {\n width: 100% !important;\n height: 100% !important;\n}', - elements: { - player: { - manual: false, - querySelectors: '.reddit-video-player-root, .media-preview-content' - } - } - } - }, }, "www.reddit.com" : { enable: ExtensionMode.Disabled, @@ -997,7 +1002,7 @@ const ExtensionConf: SettingsInterface = { enableKeyboard: ExtensionMode.All, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, type: SiteSupportLevel.CommunitySupport, defaultType: SiteSupportLevel.CommunitySupport, activeDOMConfig: 'community', @@ -1019,7 +1024,7 @@ const ExtensionConf: SettingsInterface = { enableKeyboard: ExtensionMode.Theater, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, type: SiteSupportLevel.CommunitySupport, defaultType: SiteSupportLevel.CommunitySupport, activeDOMConfig: 'community', @@ -1035,7 +1040,7 @@ const ExtensionConf: SettingsInterface = { enableAard: ExtensionMode.Theater, enableKeyboard: ExtensionMode.Theater, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, type: SiteSupportLevel.CommunitySupport, defaultType: SiteSupportLevel.CommunitySupport, activeDOMConfig: 'community', @@ -1056,7 +1061,7 @@ const ExtensionConf: SettingsInterface = { enableKeyboard: ExtensionMode.Theater, enableUI: ExtensionMode.FullScreen, - applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, + applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.UseAsDefault, type: SiteSupportLevel.CommunitySupport, defaultType: SiteSupportLevel.CommunitySupport, activeDOMConfig: 'community', diff --git a/src/ui/components/SettingsWindowContent.vue b/src/ui/components/SettingsWindowContent.vue index f98cc5f..c211707 100644 --- a/src/ui/components/SettingsWindowContent.vue +++ b/src/ui/components/SettingsWindowContent.vue @@ -37,7 +37,7 @@ v-for="suboption of tab.children" :key="suboption.id" class="suboption" - :class="{'active': suboption.id === selectedTab}" + :class="{'active': suboption.id === selectedTab, 'disabled': suboption.disabled }" @click="selectTab(suboption.id)" >
@@ -50,6 +50,9 @@ :size="32" />
+
+ {{suboption.badgeCount >= 10 ? '...' : suboption.badgeCount}} +
@@ -111,7 +114,7 @@ @@ -216,15 +219,15 @@ const AVAILABLE_TABS = { id: 'site-extension-settings', label: 'Site and Extension options', icon: 'cogs', children: [ { id: 'site-extension-settings', label: 'For this site', }, - { id: 'embedded-extension-settings', label: 'For embedded sites' }, + { id: 'embedded-extension-settings', label: 'For embedded sites', disabled: true, badgeCount: 0, }, { id: 'default-extension-settings', label: 'Default settings' } ] }, - 'extension-settings': { - id: 'extensionSettings', label: 'Site and Extension options', icon: 'cogs', + 'default-extension-settings': { + id: 'default-extension-settings', label: 'Site and Extension options', icon: 'cogs', children: [ { id: 'default-extension-settings', label: 'Default settings' }, - { id: 'website-extension-list', label: 'Website settings', }, + { id: 'website-extension-settings', label: 'Website exceptions', }, ] }, 'siteSettings': {id: 'extensionSettings', label: 'Site and Extension options', icon: 'cogs' }, @@ -246,7 +249,7 @@ const AVAILABLE_TABS = { const TAB_LOADOUT = { 'settings': [ - 'extension-settings', + 'default-extension-settings', 'settings.player-element-settings', 'autodetectionSettings', 'ui-settings', @@ -331,7 +334,7 @@ export default defineComponent({ // THINGS WILL NOT WORK IF YOU USE ARROWS siteSupportLevel() { return (this.site && this.siteSettings) ? this.siteSettings.data.type || 'no-support' : 'waiting'; - } + }, }, created() { this.generateTabs(); @@ -370,6 +373,9 @@ export default defineComponent({ */ updateSite(newSite: {host: string, hostnames: string[],}) { this.siteSettings = this.settings.getSiteSettings({site: newSite.host}); + + this.generateTabs(newSite); + this.$nextTick( () => this.$forceUpdate()); }, /** @@ -378,14 +384,26 @@ export default defineComponent({ getUrl(url) { return BrowserDetect.getURL(url); }, - generateTabs() { + generateTabs(site = this.site) { const tabs = []; for (const tab of TAB_LOADOUT[this.role]) { if (!AVAILABLE_TABS[tab]) { console.warn('[uw:SettingsWindowContent] tab', tab, 'is not present in available tabs:', AVAILABLE_TABS, '— tabs for role', this.role, TAB_LOADOUT[this.role]); continue; } else { - console.log('pushing tab:', tab, AVAILABLE_TABS[tab]) + if (tab === 'site-extension-settings') { + const frames = AVAILABLE_TABS[tab].children?.find(x => x.id === 'embedded-extension-settings'); + if (frames) { + let frameCount = site?.hostnames?.length; + + if (site?.hostnames?.includes(site.host)) { + frameCount--; + } + + frames.badgeCount = frameCount; + frames.disabled = !frameCount; + } + } tabs.push(AVAILABLE_TABS[tab]); } } @@ -451,6 +469,9 @@ export default defineComponent({ @apply !bg-transparent !text-primary-300 bg-gradient-to-r from-transparent to-black hover:!text-primary-200 ; } } + &.disabled { + @apply pointer-events-none; + } } .main-tab { @@ -471,7 +492,8 @@ export default defineComponent({ .suboption { @apply px-6 py-2 - text-[1.125rem] text-stone-500 font-mono + uppercase text-stone-400/75 font-mono + relative hover:bg-stone-800 hover:text-primary-200 hover:border-r-stone-600; @@ -479,6 +501,17 @@ export default defineComponent({ &.active { @apply !bg-transparent !text-primary-300 bg-gradient-to-r from-transparent to-black hover:!text-primary-200; } + &.disabled { + @apply pointer-events-none text-stone-600/75; + } + .badge { + @apply absolute right-[0.25rem] bottom-0 w-4 h-4 text-stone-950 bg-primary-300 rounded flex justify-center items-center font-bold text-[0.8rem]; + } + + &:last-child { + @apply + mb-2; + } } } } diff --git a/src/ui/components/segments/ExtensionInfo/segments/ChangelogContent.vue b/src/ui/components/segments/ExtensionInfo/segments/ChangelogContent.vue index dc2b410..7efdaba 100644 --- a/src/ui/components/segments/ExtensionInfo/segments/ChangelogContent.vue +++ b/src/ui/components/segments/ExtensionInfo/segments/ChangelogContent.vue @@ -5,7 +5,11 @@ Potentially breaking: Autodetection: diff --git a/src/ui/components/segments/ExtensionSettings/Panels/FrameSiteSettings.vue b/src/ui/components/segments/ExtensionSettings/Panels/FrameSiteSettings.vue index 767d1bb..9bd0230 100644 --- a/src/ui/components/segments/ExtensionSettings/Panels/FrameSiteSettings.vue +++ b/src/ui/components/segments/ExtensionSettings/Panels/FrameSiteSettings.vue @@ -9,12 +9,14 @@ -
- +
+