Simplify extensionMode things

This commit is contained in:
Tamius Han 2025-12-10 22:49:59 +01:00
parent 877fc96da1
commit ee32ae93c3
13 changed files with 163 additions and 428 deletions

View File

@ -1,10 +1,9 @@
enum ExtensionMode { enum ExtensionMode {
AutoDisabled = -2,
Disabled = -1, Disabled = -1,
Default = 0, Default = 0,
Whitelist = 1, FullScreen = 1,
Basic = 2, Theater = 2,
Enabled = 3, All = 3
}; }
export default ExtensionMode; export default ExtensionMode;

View File

@ -1,4 +1,4 @@
enum ExtensionMode { enum LegacyExtensionMode {
AutoDisabled = -2, AutoDisabled = -2,
Disabled = -1, Disabled = -1,
Default = 0, Default = 0,
@ -7,4 +7,4 @@ enum ExtensionMode {
Enabled = 3, Enabled = 3,
}; };
export default ExtensionMode; export default LegacyExtensionMode;

View File

@ -10,9 +10,9 @@ import StretchType from '../enums/StretchType.enum'
import VideoAlignmentType from '../enums/VideoAlignmentType.enum' import VideoAlignmentType from '../enums/VideoAlignmentType.enum'
export enum ExtensionEnvironment { export enum ExtensionEnvironment {
Normal = 'normal', Normal = ExtensionMode.All,
Theater = 'theater', Theater = ExtensionMode.Theater,
Fullscreen = 'fullscreen', Fullscreen = ExtensionMode.FullScreen,
} }
export interface DevUiConfig { export interface DevUiConfig {
@ -48,12 +48,6 @@ interface RestrictionsSettings {
onlyAllowAutodetectionInFullScreen?: boolean; // if enabled, autodetection will only start once in full screen onlyAllowAutodetectionInFullScreen?: boolean; // if enabled, autodetection will only start once in full screen
} }
interface ExtensionEnvironmentSettingsInterface {
normal: ExtensionMode,
theater: ExtensionMode,
fullscreen: ExtensionMode,
}
export interface CommandInterface { export interface CommandInterface {
action: string, action: string,
label: string, label: string,
@ -445,10 +439,10 @@ interface SettingsInterface {
} }
export interface SiteSettingsInterface { export interface SiteSettingsInterface {
enable: ExtensionEnvironmentSettingsInterface; enable: ExtensionMode;
enableAard: ExtensionEnvironmentSettingsInterface; enableAard: ExtensionMode;
enableKeyboard: ExtensionEnvironmentSettingsInterface; enableKeyboard: ExtensionMode;
enableUI: ExtensionEnvironmentSettingsInterface; // Lies! enableUI doesn't use 'theater' property (but uses the other two) enableUI: ExtensionMode;
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy; // presumed to be 'Always' if not defined applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy; // presumed to be 'Always' if not defined
overrideWhenEmbedded?: boolean; overrideWhenEmbedded?: boolean;

View File

@ -1,41 +1,44 @@
// How to use: // How to use:
// version: {ExtensionConf object, but only properties that get overwritten} // version: {ExtensionConf object, but only properties that get overwritten}
import StretchType from '../../common/enums/StretchType.enum'; import StretchType from '../../common/enums/StretchType.enum';
import ExtensionMode from '../../common/enums/ExtensionMode.enum'; // import ExtensionMode from '../../common/enums/ExtensionMode.enum';
import VideoAlignmentType from '../../common/enums/VideoAlignmentType.enum'; import VideoAlignmentType from '../../common/enums/VideoAlignmentType.enum';
import BrowserDetect from './BrowserDetect'; import BrowserDetect from './BrowserDetect';
import SettingsInterface from '../../common/interfaces/SettingsInterface'; import SettingsInterface, { SiteSettingsInterface } from '../../common/interfaces/SettingsInterface';
import { _cp } from '../../common/js/utils'; import { _cp } from '../../common/js/utils';
import CropModePersistence from '../../common/enums/CropModePersistence.enum'; import CropModePersistence from '../../common/enums/CropModePersistence.enum';
import AspectRatioType from '../../common/enums/AspectRatioType.enum'; import AspectRatioType from '../../common/enums/AspectRatioType.enum';
import { update } from 'lodash'; import { update } from 'lodash';
import EmbeddedContentSettingsOverridePolicy from '../../common/enums/EmbeddedContentSettingsOverridePolicy.enum'; import EmbeddedContentSettingsOverridePolicy from '../../common/enums/EmbeddedContentSettingsOverridePolicy.enum';
import LegacyExtensionMode from '../../common/enums/LegacyExtensionMode.enum';
import ExtensionMode from '../../common/enums/ExtensionMode.enum';
const ExtensionConfPatch = Object.freeze([ const ExtensionConfPatch = Object.freeze([
{ {
forVersion: '6.2.4', forVersion: '6.2.4',
updateFn: (userOptions: SettingsInterface, defaultOptions) => { updateFn: (userOptions: any, defaultOptions) => {
for (const site in userOptions.sites) { for (const site in userOptions.sites) {
userOptions.sites[site].enableUI = { (userOptions as any).sites[site].enableUI = {
fullscreen: ExtensionMode.Default, fullscreen: LegacyExtensionMode.Default,
theater: ExtensionMode.Default, theater: LegacyExtensionMode.Default,
normal: ExtensionMode.Default, normal: LegacyExtensionMode.Default,
} }
} }
userOptions.sites['@global'].enableUI = { userOptions.sites['@global'].enableUI = {
fullscreen: userOptions.ui.inPlayer.enabled ? ExtensionMode.Enabled : ExtensionMode.Disabled, fullscreen: userOptions.ui.inPlayer.enabled ? LegacyExtensionMode.Enabled : LegacyExtensionMode.Disabled,
theater: ExtensionMode.Enabled, theater: LegacyExtensionMode.Enabled,
normal: (userOptions.ui.inPlayer.enabled && !userOptions.ui.inPlayer.enabledFullscreenOnly) ? ExtensionMode.Enabled : ExtensionMode.Disabled normal: (userOptions.ui.inPlayer.enabled && !userOptions.ui.inPlayer.enabledFullscreenOnly) ? LegacyExtensionMode.Enabled : LegacyExtensionMode.Disabled
} }
userOptions.sites['@empty'].enableUI = { userOptions.sites['@empty'].enableUI = {
fullscreen: ExtensionMode.Default, fullscreen: LegacyExtensionMode.Default,
theater: ExtensionMode.Default, theater: LegacyExtensionMode.Default,
normal: ExtensionMode.Default, normal: LegacyExtensionMode.Default,
} }
} }
}, { }, {
forVersion: '6.2.6', forVersion: '6.2.6',
updateFn: (userOptions: SettingsInterface, defaultOptions) => { updateFn: (userOptions: any, defaultOptions) => {
console.log('[ultrawidify] Migrating settings — applying patches for version 6.2.6'); console.log('[ultrawidify] Migrating settings — applying patches for version 6.2.6');
if (!userOptions.commands) { if (!userOptions.commands) {
@ -241,7 +244,7 @@ const ExtensionConfPatch = Object.freeze([
} }
}, { }, {
forVersion: '6.3.92', forVersion: '6.3.92',
updateFn: (userOptions: SettingsInterface) => { updateFn: (userOptions: any) => {
// applyToEmbeddedContent is now an enum, and also no longer optional // applyToEmbeddedContent is now an enum, and also no longer optional
for (const site in userOptions.sites) { for (const site in userOptions.sites) {
if (userOptions.sites[site].applyToEmbeddedContent === undefined) { if (userOptions.sites[site].applyToEmbeddedContent === undefined) {
@ -275,6 +278,33 @@ const ExtensionConfPatch = Object.freeze([
userOptions.aardLegacy = defaultOptions.aardLegacy; userOptions.aardLegacy = defaultOptions.aardLegacy;
delete (userOptions as any).arDetect; delete (userOptions as any).arDetect;
} }
},
{
forVersion: '6.3.994',
upgradeFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface) => {
const convertLegacyExtensionMode = (option: {normal: LegacyExtensionMode, theater: LegacyExtensionMode, fullscreen: LegacyExtensionMode}) => {
if (option.normal === LegacyExtensionMode.Enabled) {
return ExtensionMode.All;
}
if (option.theater === LegacyExtensionMode.Enabled) {
return ExtensionMode.Theater;
}
if (option.fullscreen === LegacyExtensionMode.Enabled) {
return ExtensionMode.FullScreen;
}
if (option.fullscreen === LegacyExtensionMode.Disabled) {
return ExtensionMode.Disabled;
}
return ExtensionMode.Default;
}
for (const key in userOptions.sites) {
userOptions.sites[key].enable = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
userOptions.sites[key].enableAard = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
userOptions.sites[key].enableKeyboard = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
userOptions.sites[key].enableUI = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
}
}
} }
]); ]);

View File

@ -757,65 +757,6 @@ const ExtensionConf: SettingsInterface = {
arguments: { arguments: {
arPersistence: CropModePersistence.Default arPersistence: CropModePersistence.Default
} }
}, {
action: 'set-extension-enabled',
label: 'Enable extension',
arguments: {
mode: ExtensionMode.Enabled,
},
internalOnly: true,
}, {
action: 'set-extension-enabled',
label: 'Whitelist',
arguments: {
mode: ExtensionMode.Whitelist,
},
internalOnly: true,
}, {
action: 'set-extension-enabled',
label: 'Disable',
arguments: {
mode: ExtensionMode.Disabled
},
internalOnly: true,
}, {
action: 'set-extension-enabled',
label: 'Use default option',
arguments: {
mode: ExtensionMode.Default
},
internalOnly: true
}, {
action: 'set-autoar-enabled',
label: 'Enabled',
comment: 'Enable automatic aspect ratio detection if possible',
arguments: {
mode: ExtensionMode.Enabled
},
internalOnly: true
}, {
action: 'set-autoar-enabled',
label: 'Whitelist',
comment: 'Enable automatic aspect ratio detection if possible, but only on whitelisted sites',
arguments: {
mode: ExtensionMode.Whitelist,
},
internalOnly: true,
}, {
action: 'set-autoar-enabled',
label: 'Disable',
comment: 'Disable aspect ratio detection',
arguments: {
mode: ExtensionMode.Disabled
},
internalOnly: true,
}, {
action: 'set-autoar-enabled',
label: 'Use default option',
arguments: {
mode: ExtensionMode.Default
},
internalOnly: true
}] }]
}, },
mitigations: { mitigations: {
@ -862,26 +803,11 @@ const ExtensionConf: SettingsInterface = {
// to avoid writing this multiple times. Tags: // to avoid writing this multiple times. Tags:
// #g — only available in @global // #g — only available in @global
// #s — only available for specific site // #s — only available for specific site
enable: { // How should extension work: enable: ExtensionMode.Disabled,
fullscreen: ExtensionMode.Disabled, // 'enabled' - work everywhere except blacklist enableAard: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled, // enableKeyboard: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled, // 'disabled' - work nowhere enableUI: ExtensionMode.FullScreen,
}, // 'default' - follow global rules (#s)
enableAard: { // Should we try to automatically detect aspect ratio?
fullscreen: ExtensionMode.Disabled, // Options: 'enabled', 'default' (#s), 'disabled'
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled
},
enableUI: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled, // Lies! means 'theater-ish'
normal: ExtensionMode.Disabled // Not actually used.
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
defaultType: 'unknown', defaultType: 'unknown',
@ -894,26 +820,11 @@ const ExtensionConf: SettingsInterface = {
} }
}, },
"@empty": { // placeholder settings object with fallbacks to @global "@empty": { // placeholder settings object with fallbacks to @global
enable: { enable: ExtensionMode.Default,
fullscreen: ExtensionMode.Default, enableAard: ExtensionMode.Default,
theater: ExtensionMode.Default, enableKeyboard: ExtensionMode.Default,
normal: ExtensionMode.Default, enableUI: ExtensionMode.Default,
},
enableAard: {
fullscreen: ExtensionMode.Default,
theater: ExtensionMode.Default,
normal: ExtensionMode.Default,
},
enableKeyboard: {
fullscreen: ExtensionMode.Default,
theater: ExtensionMode.Default,
normal: ExtensionMode.Default
},
enableUI: {
fullscreen: ExtensionMode.Default,
theater: ExtensionMode.Default,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: 'user-defined', type: 'user-defined',
@ -926,26 +837,11 @@ const ExtensionConf: SettingsInterface = {
} }
}, },
"www.youtube.com" : { "www.youtube.com" : {
enable: { enable: ExtensionMode.All,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.All,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.All,
normal: ExtensionMode.Enabled, enableUI: ExtensionMode.All,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
overrideWhenEmbedded: true, overrideWhenEmbedded: true,
override: false, // ignore value localStorage in favour of this override: false, // ignore value localStorage in favour of this
@ -967,26 +863,11 @@ const ExtensionConf: SettingsInterface = {
} }
}, },
"www.youtube-nocookie.com": { "www.youtube-nocookie.com": {
enable: { enable: ExtensionMode.All,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.All,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.All,
normal: ExtensionMode.Enabled, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
overrideWhenEmbedded: true, overrideWhenEmbedded: true,
@ -1009,52 +890,21 @@ const ExtensionConf: SettingsInterface = {
} }
}, },
"www.netflix.com" : { "www.netflix.com" : {
enable: { enable: ExtensionMode.Theater,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.Disabled,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.All,
normal: ExtensionMode.Default, enableUI: ExtensionMode.All,
},
enableAard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
override: false, override: false,
type: 'community', type: 'community',
defaultType: 'community', defaultType: 'community',
}, },
"www.disneyplus.com" : { "www.disneyplus.com" : {
enable: { enable: ExtensionMode.Theater,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.Theater,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.All,
normal: ExtensionMode.Default, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Default,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Default
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Default
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: 'community', type: 'community',
defaultType: 'community', defaultType: 'community',
@ -1077,51 +927,21 @@ const ExtensionConf: SettingsInterface = {
} }
}, },
"www.twitch.tv": { "www.twitch.tv": {
enable: { enable: ExtensionMode.All,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.All,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.All,
normal: ExtensionMode.Enabled, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: 'official', type: 'official',
defaultType: 'official', defaultType: 'official',
}, },
"old.reddit.com" : { "old.reddit.com" : {
enable: { enable: ExtensionMode.Disabled,
fullscreen: ExtensionMode.Disabled, enableAard: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled, enableKeyboard: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled, enableUI: ExtensionMode.Disabled,
},
enableAard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableUI: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never,
type: 'officially-disabled', type: 'officially-disabled',
defaultType: 'officially-disabled', defaultType: 'officially-disabled',
@ -1140,26 +960,11 @@ const ExtensionConf: SettingsInterface = {
}, },
}, },
"www.reddit.com" : { "www.reddit.com" : {
enable: { enable: ExtensionMode.Disabled,
fullscreen: ExtensionMode.Disabled, enableAard: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled, enableKeyboard: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled, enableUI: ExtensionMode.Disabled,
},
enableAard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableUI: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never,
type: 'officially-disabled', type: 'officially-disabled',
defaultType: 'officially-disabled', defaultType: 'officially-disabled',
@ -1178,51 +983,21 @@ const ExtensionConf: SettingsInterface = {
}, },
}, },
"imgur.com": { "imgur.com": {
enable: { enable: ExtensionMode.Disabled,
fullscreen: ExtensionMode.Disabled, enableAard: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled, enableKeyboard: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled, enableUI: ExtensionMode.Disabled,
},
enableAard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled,
},
enableUI: {
fullscreen: ExtensionMode.Disabled,
theater: ExtensionMode.Disabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Never,
type: 'officially-disabled', type: 'officially-disabled',
defaultType: 'officially-disabled', defaultType: 'officially-disabled',
}, },
"www.wakanim.tv": { "www.wakanim.tv": {
enable: { enable: ExtensionMode.All,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.All,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.All,
normal: ExtensionMode.Enabled, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Enabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: 'community', type: 'community',
defaultType: 'community', defaultType: 'community',
@ -1240,26 +1015,11 @@ const ExtensionConf: SettingsInterface = {
}, },
}, },
"app.plex.tv": { "app.plex.tv": {
enable: { enable: ExtensionMode.Theater,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.Theater,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.Theater,
normal: ExtensionMode.Disabled, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: 'community', type: 'community',
defaultType: 'community', defaultType: 'community',
@ -1272,26 +1032,10 @@ const ExtensionConf: SettingsInterface = {
} }
}, },
"metaivi.com": { "metaivi.com": {
enable: { enable: ExtensionMode.Theater,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.Theater,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.Theater,
normal: ExtensionMode.Disabled, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: "community", type: "community",
defaultType: "community", defaultType: "community",
@ -1308,26 +1052,11 @@ const ExtensionConf: SettingsInterface = {
}, },
}, },
"piped.kavin.rocks": { "piped.kavin.rocks": {
enable: { enable: ExtensionMode.Theater,
fullscreen: ExtensionMode.Enabled, enableAard: ExtensionMode.Theater,
theater: ExtensionMode.Enabled, enableKeyboard: ExtensionMode.Theater,
normal: ExtensionMode.Disabled, enableUI: ExtensionMode.FullScreen,
},
enableAard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled,
},
enableKeyboard: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
enableUI: {
fullscreen: ExtensionMode.Enabled,
theater: ExtensionMode.Enabled,
normal: ExtensionMode.Disabled
},
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always, applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Always,
type: "community", type: "community",
defaultType: "community", defaultType: "community",

View File

@ -263,7 +263,7 @@ export class Aard {
// console.log('--- video data: ---\n', this.videoData); // console.log('--- video data: ---\n', this.videoData);
return; return;
} }
if (this.siteSettings.data.enableAard[this.videoData.player.environment] === ExtensionMode.Enabled) { if (this.siteSettings.data.enableAard <= this.videoData.player.environment) {
this.start(); this.start();
} else { } else {
this.stop(); this.stop();

View File

@ -1,5 +1,4 @@
import AspectRatioType from '@src/common/enums/AspectRatioType.enum'; import AspectRatioType from '@src/common/enums/AspectRatioType.enum';
import ExtensionMode from '@src/common/enums/ExtensionMode.enum';
import { ArVariant } from '@src/common/interfaces/ArInterface'; import { ArVariant } from '@src/common/interfaces/ArInterface';
import { ExtensionEnvironment } from '@src/common/interfaces/SettingsInterface'; import { ExtensionEnvironment } from '@src/common/interfaces/SettingsInterface';
import EventBus from '../EventBus'; import EventBus from '../EventBus';
@ -16,15 +15,10 @@ import { GlDebugCanvas, GlDebugType } from './gl/GlDebugCanvas';
import { AardCanvasStore } from './interfaces/aard-canvas-store.interface'; import { AardCanvasStore } from './interfaces/aard-canvas-store.interface';
import { AardDetectionSample, generateSampleArray, resetSamples } from './interfaces/aard-detection-sample.interface'; import { AardDetectionSample, generateSampleArray, resetSamples } from './interfaces/aard-detection-sample.interface';
import { AardStatus, initAardStatus } from './interfaces/aard-status.interface'; import { AardStatus, initAardStatus } from './interfaces/aard-status.interface';
import { AardTestResult_SubtitleRegion, AardTestResults, resetSubtitleScanResults } from './interfaces/aard-test-results.interface';
import { AardTimers, initAardTimers } from './interfaces/aard-timers.interface'; import { AardTimers, initAardTimers } from './interfaces/aard-timers.interface';
import { ComponentLogger } from '../logging/ComponentLogger'; import { ComponentLogger } from '../logging/ComponentLogger';
import { AardPollingOptions } from './enums/aard-polling-options.enum'; import { AardPollingOptions } from './enums/aard-polling-options.enum';
import { AardSubtitleCropMode } from './enums/aard-subtitle-crop-mode.enum';
import { LetterboxOrientation } from './enums/letterbox-orientation.enum';
import { Edge } from './enums/edge.enum';
import { AardUncertainReason } from './enums/aard-letterbox-uncertain-reason.enum'; import { AardUncertainReason } from './enums/aard-letterbox-uncertain-reason.enum';
import { result } from 'lodash';
import { AardLegacyTestResults, initAardTestResults, resetAardTestResults, resetGuardLine } from './interfaces/aard-legacy-test-results.interface'; import { AardLegacyTestResults, initAardTestResults, resetAardTestResults, resetGuardLine } from './interfaces/aard-legacy-test-results.interface';
@ -439,7 +433,7 @@ export class AardLegacy {
// console.log('--- video data: ---\n', this.videoData); // console.log('--- video data: ---\n', this.videoData);
return; return;
} }
if (this.siteSettings.data.enableAard[this.videoData.player.environment] === ExtensionMode.Enabled) { if (this.videoData.player.environment <= this.siteSettings.data.enableAard) {
this.start(); this.start();
} else { } else {
this.stop(); this.stop();

View File

@ -107,8 +107,8 @@ export class KeyboardHandler extends KbmBase {
} }
} }
setKeyboardLocal(state) { setKeyboardLocal(state: ExtensionMode) {
if (state === ExtensionMode.Enabled) { if (state === ExtensionMode.All) {
this.keyboardLocalDisabled = false; this.keyboardLocalDisabled = false;
} else if (state === ExtensionMode.Disabled) { } else if (state === ExtensionMode.Disabled) {
this.keyboardLocalDisabled = true; this.keyboardLocalDisabled = true;

View File

@ -1,6 +1,6 @@
import CropModePersistence from '../../../common/enums/CropModePersistence.enum'; import CropModePersistence from '../../../common/enums/CropModePersistence.enum';
import ExtensionMode from '../../../common/enums/ExtensionMode.enum'; import ExtensionMode from '../../../common/enums/ExtensionMode.enum';
import { SettingsReloadComponent, SettingsReloadFlags, SiteSettingsInterface } from '../../../common/interfaces/SettingsInterface'; import { ExtensionEnvironment, SettingsReloadComponent, SettingsReloadFlags, SiteSettingsInterface } from '../../../common/interfaces/SettingsInterface';
import { _cp } from '../../../common/js/utils'; import { _cp } from '../../../common/js/utils';
import Settings from './Settings'; import Settings from './Settings';
import StretchType from '../../../common/enums/StretchType.enum'; import StretchType from '../../../common/enums/StretchType.enum';
@ -216,10 +216,8 @@ export class SiteSettings {
if (!this.data[enableSegment]) { if (!this.data[enableSegment]) {
this.data[enableSegment] = {}; this.data[enableSegment] = {};
} }
for (const environment of ['normal', 'theater', 'fullscreen']) { if (!this.data[enableSegment] || this.data[enableSegment] === ExtensionMode.Default) {
if (!this.data[enableSegment][environment] || this.data[enableSegment][environment] === ExtensionMode.Default) { this.data[enableSegment] = _cp(this.defaultSettings[enableSegment]);
this.data[enableSegment][environment] = _cp(this.defaultSettings[enableSegment][environment]);
}
} }
} }
@ -339,14 +337,14 @@ export class SiteSettings {
} }
} }
private _getEnvironment(isTheater: boolean, isFullscreen: boolean): 'fullscreen' | 'theater' | 'normal' { private _getEnvironment(isTheater: boolean, isFullscreen: boolean): ExtensionEnvironment {
if (isFullscreen) { if (isFullscreen) {
return 'fullscreen'; return ExtensionEnvironment.Fullscreen;
} }
if (isTheater) { if (isTheater) {
return 'theater'; return ExtensionEnvironment.Theater;
} }
return 'normal'; return ExtensionEnvironment.Normal;
} }
/** /**
@ -355,9 +353,9 @@ export class SiteSettings {
* @param isFullscreen * @param isFullscreen
* @returns ExtensionMode * @returns ExtensionMode
*/ */
isEnabledForEnvironment(isTheater: boolean, isFullscreen: boolean): ExtensionMode { isEnabledForEnvironment(isTheater: boolean, isFullscreen: boolean): boolean {
const env = this._getEnvironment(isTheater, isFullscreen); const env = this._getEnvironment(isTheater, isFullscreen);
return this.data.enable[env]; return env <= this.data.enable;
} }
/** /**
@ -366,9 +364,9 @@ export class SiteSettings {
* @param isFullscreen * @param isFullscreen
* @returns * @returns
*/ */
isAardEnabledForEnvironment(isTheater: boolean, isFullscreen: boolean): ExtensionMode { isAardEnabledForEnvironment(isTheater: boolean, isFullscreen: boolean): boolean {
const env = this._getEnvironment(isTheater, isFullscreen); const env = this._getEnvironment(isTheater, isFullscreen);
return this.data.enableAard[env]; return env <= this.data.enableAard;
} }
/** /**
@ -377,9 +375,9 @@ export class SiteSettings {
* @param isFullscreen * @param isFullscreen
* @returns * @returns
*/ */
isKeyboardEnabledForEnvironment(isTheater: boolean, isFullscreen: boolean): ExtensionMode { isKeyboardEnabledForEnvironment(isTheater: boolean, isFullscreen: boolean): boolean {
const env = this._getEnvironment(isTheater, isFullscreen); const env = this._getEnvironment(isTheater, isFullscreen);
return this.data.enableKeyboard[env]; return env <= this.data.enableKeyboard;
} }
//#endregion //#endregion

View File

@ -53,9 +53,7 @@ class UI {
return true; return true;
} }
return this.siteSettings?.data.enableUI.fullscreen === ExtensionMode.Enabled return this.siteSettings?.data.enableUI !== ExtensionMode.Disabled;
|| this.siteSettings?.data.enableUI.theater === ExtensionMode.Enabled
|| this.siteSettings?.data.enableUI.normal === ExtensionMode.Enabled;
} }
async init() { async init() {
@ -342,7 +340,7 @@ class UI {
canShowUI: false, canShowUI: false,
} }
if (this.playerData?.environment && this.siteSettings.data.enableUI[this.playerData?.environment] !== ExtensionMode.Enabled) { if (this.playerData?.environment && this.playerData?.environment <= this.siteSettings.data.enableUI) {
return result; return result;
} }

View File

@ -1,4 +1,3 @@
import ExtensionMode from '../../../common/enums/ExtensionMode.enum';
import EventBus from '../EventBus'; import EventBus from '../EventBus';
import { SiteSettings } from '../settings/SiteSettings'; import { SiteSettings } from '../settings/SiteSettings';
@ -19,9 +18,9 @@ export class ExtensionStatus {
return this.fsStatus.fullscreen; return this.fsStatus.fullscreen;
} }
private enabled: ExtensionMode; private enabled: boolean;
private aardEnabled: ExtensionMode; private aardEnabled: boolean;
private kbdEnabled: ExtensionMode; private kbdEnabled: boolean;
constructor(siteSettings: SiteSettings, eventBus: EventBus, fsStatus: {fullscreen: boolean}){ constructor(siteSettings: SiteSettings, eventBus: EventBus, fsStatus: {fullscreen: boolean}){
this.siteSettings = siteSettings; this.siteSettings = siteSettings;
@ -33,26 +32,20 @@ export class ExtensionStatus {
const canAard = this.siteSettings.isAardEnabledForEnvironment(this.isTheaterMode, this.isFullScreen); const canAard = this.siteSettings.isAardEnabledForEnvironment(this.isTheaterMode, this.isFullScreen);
const canKbd = this.siteSettings.isKeyboardEnabledForEnvironment(this.isTheaterMode, this.isFullScreen); const canKbd = this.siteSettings.isKeyboardEnabledForEnvironment(this.isTheaterMode, this.isFullScreen);
if (canRun !== this.enabled) { if (canRun) {
if (canRun === ExtensionMode.Enabled) { this.eventBus.send('set-extension-active', {});
this.eventBus.send('set-extension-active', {}); } else {
} else { this.eventBus.send('set-extension-inactive', {});
this.eventBus.send('set-extension-inactive', {});
}
} }
if (canAard !== this.aardEnabled) { if (canAard) {
if (canAard === ExtensionMode.Enabled) { this.eventBus.send('set-aard-active', {});
this.eventBus.send('set-aard-active', {}); } else {
} else { this.eventBus.send('set-aard-inactive', {});
this.eventBus.send('set-aard-inactive', {});
}
} }
if (canKbd !== this.kbdEnabled) { if (canKbd) {
if (canKbd === ExtensionMode.Enabled) { this.eventBus.send('set-kbd-active', {});
this.eventBus.send('set-kbd-active', {}); } else {
} else { this.eventBus.send('set-kbd-inactive', {});
this.eventBus.send('set-kbd-inactive', {});
}
} }
this.enabled = canRun; this.enabled = canRun;

View File

@ -478,7 +478,7 @@ class PlayerData {
this.isTooSmall = this.checkIfTooSmall(); this.isTooSmall = this.checkIfTooSmall();
} }
const canEnable = this.siteSettings.isEnabledForEnvironment(this.isFullscreen, this.isTheaterMode) === ExtensionMode.Enabled; const canEnable = this.siteSettings.isEnabledForEnvironment(this.isFullscreen, this.isTheaterMode);
if (this.runLevel === RunLevel.Off && canEnable) { if (this.runLevel === RunLevel.Off && canEnable) {
this.eventBus.send('restore-ar', null); this.eventBus.send('restore-ar', null);

View File

@ -408,7 +408,7 @@ class VideoData {
this.logger.warn('onEnvironmentChanged', 'environment changed from:', this.currentEnvironment, 'to:', this.player.environment); this.logger.warn('onEnvironmentChanged', 'environment changed from:', this.currentEnvironment, 'to:', this.player.environment);
this.currentEnvironment = this.player.environment; this.currentEnvironment = this.player.environment;
if (this.siteSettings.data.enable[this.player.environment] === ExtensionMode.Disabled) { if (this.player.environment <= this.siteSettings.data.enable) {
this.setRunLevel(RunLevel.Off); this.setRunLevel(RunLevel.Off);
} else { } else {
this.restoreAr(); this.restoreAr();
@ -417,7 +417,7 @@ class VideoData {
} }
setRunLevel(runLevel: RunLevel, options?: {fromPlayer?: boolean}) { setRunLevel(runLevel: RunLevel, options?: {fromPlayer?: boolean}) {
if (this.player && this.siteSettings.data.enable[this.player.environment] !== ExtensionMode.Enabled) { if (this.player && this.siteSettings.data.enable >= this.player.environment) {
runLevel = RunLevel.Off; runLevel = RunLevel.Off;
} }