From 085bd4aab90155018e99b2f6bc8b562e3563edbe Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 16 Apr 2023 02:16:57 +0200 Subject: [PATCH] fix video alignment default settings --- src/ext/conf/ExtConfPatches.ts | 11 +++++++++++ src/ext/conf/ExtensionConf.ts | 3 ++- src/ext/lib/settings/SiteSettings.ts | 8 ++++---- src/manifest.json | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ext/conf/ExtConfPatches.ts b/src/ext/conf/ExtConfPatches.ts index bf46c02..5bcda1f 100644 --- a/src/ext/conf/ExtConfPatches.ts +++ b/src/ext/conf/ExtConfPatches.ts @@ -253,6 +253,17 @@ const ExtensionConfPatch = [ }, }) } + }, { + forVersion: '5.99.5', + updateFn: (userOptions: SettingsInterface, defaultOptions) => { + if (!userOptions.sites['@global'].defaults.alignment || !userOptions.sites['@global'].defaults.alignment.x || !userOptions.sites['@global'].defaults.alignment.y) { + userOptions.sites['@global'].defaults.alignment = { + x: VideoAlignmentType.Center, + y: VideoAlignmentType.Center + }; + } + userOptions.sites['@empty'].defaults.alignment = {x: VideoAlignmentType.Default, y: VideoAlignmentType.Default}; + } } ]; diff --git a/src/ext/conf/ExtensionConf.ts b/src/ext/conf/ExtensionConf.ts index b21d1f9..33133ef 100644 --- a/src/ext/conf/ExtensionConf.ts +++ b/src/ext/conf/ExtensionConf.ts @@ -1447,8 +1447,8 @@ const ExtensionConf: SettingsInterface = { defaults: { crop: {type: AspectRatioType.Reset}, // does NOT override Aard stretch: StretchType.NoStretch, + alignment: {x: VideoAlignmentType.Center, y: VideoAlignmentType.Center}, } - }, "@empty": { // placeholder settings object with fallbacks to @global enable: { @@ -1471,6 +1471,7 @@ const ExtensionConf: SettingsInterface = { defaults: { crop: null, stretch: StretchType.Default, + alignment: {x: VideoAlignmentType.Default, y: VideoAlignmentType.Default}, } }, "www.youtube.com" : { diff --git a/src/ext/lib/settings/SiteSettings.ts b/src/ext/lib/settings/SiteSettings.ts index f472df8..349bf95 100644 --- a/src/ext/lib/settings/SiteSettings.ts +++ b/src/ext/lib/settings/SiteSettings.ts @@ -66,16 +66,16 @@ export class SiteSettings { // these can contain default options, but can also be undefined if (this.data.defaults?.stretch === StretchType.Default || this.data.defaults?.stretch === undefined) { - this.data.defaults.stretch = _cp(this.defaultSettings.defaults.stretch); + this.data.defaults.stretch = _cp(this.defaultSettings.defaults.stretch ?? StretchType.NoStretch); } if (this.data.defaults?.alignment === undefined) { // distinguish between undefined and 0! - this.data.defaults.alignment = _cp(this.defaultSettings.defaults.alignment); + this.data.defaults.alignment = _cp(this.defaultSettings.defaults.alignment ?? {x: VideoAlignmentType.Center, y: VideoAlignmentType.Center}); } else { if (this.data.defaults?.alignment.x === VideoAlignmentType.Default) { - this.data.defaults.alignment.x = _cp(this.defaultSettings.defaults.alignment.x); + this.data.defaults.alignment.x = _cp(this.defaultSettings.defaults.alignment.x ?? VideoAlignmentType.Center); } if (this.data.defaults.alignment.y === VideoAlignmentType.Default) { - this.data.defaults.alignment.y = _cp(this.defaultSettings.defaults.alignment.y); + this.data.defaults.alignment.y = _cp(this.defaultSettings.defaults.alignment.y ?? VideoAlignmentType.Center); } } } diff --git a/src/manifest.json b/src/manifest.json index ffbc406..b6d3a5e 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Ultrawidify", "description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.", - "version": "5.99.0-4", + "version": "5.99.5", "applications": { "gecko": { "id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}"