2019-07-05 23:45:29 +02:00
|
|
|
// How to use:
|
|
|
|
|
// version: {ExtensionConf object, but only properties that get overwritten}
|
2021-02-08 23:04:54 +01:00
|
|
|
import StretchType from '../../common/enums/StretchType.enum';
|
2025-12-10 22:49:59 +01:00
|
|
|
// import ExtensionMode from '../../common/enums/ExtensionMode.enum';
|
2021-02-08 23:04:54 +01:00
|
|
|
import VideoAlignmentType from '../../common/enums/VideoAlignmentType.enum';
|
2021-04-05 03:30:29 +02:00
|
|
|
import BrowserDetect from './BrowserDetect';
|
2025-12-10 22:49:59 +01:00
|
|
|
import SettingsInterface, { SiteSettingsInterface } from '../../common/interfaces/SettingsInterface';
|
2023-01-07 03:05:17 +01:00
|
|
|
import { _cp } from '../../common/js/utils';
|
2023-01-15 22:11:47 +01:00
|
|
|
import CropModePersistence from '../../common/enums/CropModePersistence.enum';
|
2023-03-30 00:45:34 +02:00
|
|
|
import AspectRatioType from '../../common/enums/AspectRatioType.enum';
|
2025-04-20 16:11:17 +02:00
|
|
|
import { update } from 'lodash';
|
2025-08-03 02:37:05 +02:00
|
|
|
import EmbeddedContentSettingsOverridePolicy from '../../common/enums/EmbeddedContentSettingsOverridePolicy.enum';
|
2025-12-10 22:49:59 +01:00
|
|
|
import LegacyExtensionMode from '../../common/enums/LegacyExtensionMode.enum';
|
|
|
|
|
import ExtensionMode from '../../common/enums/ExtensionMode.enum';
|
|
|
|
|
|
2019-07-05 23:45:29 +02:00
|
|
|
|
2025-04-26 01:11:31 +02:00
|
|
|
const ExtensionConfPatch = Object.freeze([
|
2019-09-03 00:28:35 +02:00
|
|
|
{
|
2025-01-27 02:59:30 +01:00
|
|
|
forVersion: '6.2.4',
|
2025-12-11 02:43:39 +01:00
|
|
|
updateFn: (userOptions: any, defaultOptions, logger?) => {
|
2025-01-27 02:59:30 +01:00
|
|
|
for (const site in userOptions.sites) {
|
2025-12-10 22:49:59 +01:00
|
|
|
(userOptions as any).sites[site].enableUI = {
|
|
|
|
|
fullscreen: LegacyExtensionMode.Default,
|
|
|
|
|
theater: LegacyExtensionMode.Default,
|
|
|
|
|
normal: LegacyExtensionMode.Default,
|
2025-01-27 02:59:30 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
userOptions.sites['@global'].enableUI = {
|
2025-12-10 22:49:59 +01:00
|
|
|
fullscreen: userOptions.ui.inPlayer.enabled ? LegacyExtensionMode.Enabled : LegacyExtensionMode.Disabled,
|
|
|
|
|
theater: LegacyExtensionMode.Enabled,
|
|
|
|
|
normal: (userOptions.ui.inPlayer.enabled && !userOptions.ui.inPlayer.enabledFullscreenOnly) ? LegacyExtensionMode.Enabled : LegacyExtensionMode.Disabled
|
2025-01-27 02:59:30 +01:00
|
|
|
}
|
|
|
|
|
userOptions.sites['@empty'].enableUI = {
|
2025-12-10 22:49:59 +01:00
|
|
|
fullscreen: LegacyExtensionMode.Default,
|
|
|
|
|
theater: LegacyExtensionMode.Default,
|
|
|
|
|
normal: LegacyExtensionMode.Default,
|
2025-01-27 02:59:30 +01:00
|
|
|
}
|
|
|
|
|
}
|
2025-04-20 16:11:17 +02:00
|
|
|
}, {
|
|
|
|
|
forVersion: '6.2.6',
|
2025-12-11 02:43:39 +01:00
|
|
|
updateFn: (userOptions: any, defaultOptions, logger?) => {
|
2025-08-03 02:37:05 +02:00
|
|
|
console.log('[ultrawidify] Migrating settings — applying patches for version 6.2.6');
|
2025-04-26 01:11:31 +02:00
|
|
|
|
|
|
|
|
if (!userOptions.commands) {
|
|
|
|
|
userOptions.commands = {
|
|
|
|
|
zoom: [],
|
|
|
|
|
crop: [],
|
|
|
|
|
stretch: [],
|
|
|
|
|
pan: [],
|
|
|
|
|
internal: []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-20 16:11:17 +02:00
|
|
|
userOptions.commands.zoom = [{
|
|
|
|
|
action: 'change-zoom',
|
|
|
|
|
label: 'Zoom +5%',
|
|
|
|
|
arguments: {
|
|
|
|
|
zoom: 0.05
|
|
|
|
|
},
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 'z',
|
|
|
|
|
code: 'KeyY',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: false,
|
|
|
|
|
onKeyUp: true,
|
|
|
|
|
onKeyDown: false,
|
|
|
|
|
},
|
|
|
|
|
internalOnly: true,
|
|
|
|
|
actionId: 'change-zoom-10in'
|
|
|
|
|
}, {
|
|
|
|
|
action: 'change-zoom',
|
|
|
|
|
label: 'Zoom -5%',
|
|
|
|
|
arguments: {
|
|
|
|
|
zoom: -0.05
|
|
|
|
|
},
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 'u',
|
|
|
|
|
code: 'KeyU',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: false,
|
|
|
|
|
onKeyUp: true,
|
|
|
|
|
onKeyDown: false,
|
|
|
|
|
},
|
|
|
|
|
internalOnly: true,
|
|
|
|
|
actionId: 'change-zoom-10out'
|
|
|
|
|
}, {
|
|
|
|
|
action: 'set-zoom',
|
|
|
|
|
label: 'Reset zoom',
|
|
|
|
|
arguments: {
|
|
|
|
|
zoom: 1,
|
|
|
|
|
},
|
|
|
|
|
internalOnly: true,
|
|
|
|
|
actionId: 'set-zoom-reset'
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
delete (userOptions as any).actions;
|
2025-04-20 19:29:47 +02:00
|
|
|
|
2025-04-22 02:42:33 +02:00
|
|
|
userOptions.dev = {
|
|
|
|
|
loadFromSnapshot: false
|
|
|
|
|
};
|
2025-04-20 19:29:47 +02:00
|
|
|
userOptions.ui.dev = {
|
|
|
|
|
aardDebugOverlay: {
|
|
|
|
|
showOnStartup: false,
|
|
|
|
|
showDetectionDetails: true
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-26 01:11:31 +02:00
|
|
|
|
|
|
|
|
const newZoomActions = [{
|
|
|
|
|
action: 'set-zoom',
|
|
|
|
|
label: 'Reset zoom',
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 'r',
|
|
|
|
|
code: 'KeyR',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: true,
|
|
|
|
|
onKeyUp: true,
|
|
|
|
|
onKeyDown: false,
|
|
|
|
|
},
|
2025-05-19 01:15:05 +02:00
|
|
|
arguments: {
|
|
|
|
|
zoom: 1
|
|
|
|
|
},
|
2025-04-26 01:11:31 +02:00
|
|
|
internalOnly: true,
|
|
|
|
|
actionId: 'set-zoom-reset'
|
|
|
|
|
}, {
|
|
|
|
|
action: 'set-ar-zoom',
|
|
|
|
|
label: 'Automatic',
|
|
|
|
|
comment: 'Automatically detect aspect ratio and zoom accordingly',
|
|
|
|
|
arguments: {
|
|
|
|
|
type: AspectRatioType.Automatic
|
|
|
|
|
},
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 'a',
|
|
|
|
|
code: 'KeyA',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: true,
|
|
|
|
|
onKeyUp: true,
|
|
|
|
|
onKeyDown: false,
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
action: 'set-ar-zoom',
|
|
|
|
|
label: 'Cycle',
|
|
|
|
|
comment: 'Cycle through zoom options',
|
|
|
|
|
arguments: {
|
|
|
|
|
type: AspectRatioType.Cycle
|
|
|
|
|
},
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 'c',
|
|
|
|
|
code: 'KeyC',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: true,
|
|
|
|
|
onKeyUp: true,
|
|
|
|
|
onKeyDown: false,
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
action: 'set-ar-zoom',
|
|
|
|
|
label: '21:9',
|
|
|
|
|
comment: 'Zoom for 21:9 aspect ratio (1:2.39)',
|
|
|
|
|
arguments: {
|
|
|
|
|
type: AspectRatioType.Fixed,
|
|
|
|
|
ratio: 2.39
|
|
|
|
|
},
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 'd',
|
|
|
|
|
code: 'KeyD',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: true,
|
|
|
|
|
onKeyUp: false,
|
|
|
|
|
onKeyDown: true,
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
action: 'set-ar-zoom',
|
|
|
|
|
label: '18:9',
|
|
|
|
|
comment: 'Zoom for 18:9 aspect ratio (1:2)',
|
|
|
|
|
arguments: {
|
|
|
|
|
type: AspectRatioType.Fixed,
|
|
|
|
|
ratio: 1.78
|
|
|
|
|
},
|
|
|
|
|
shortcut: {
|
|
|
|
|
key: 's',
|
|
|
|
|
code: 'KeyS',
|
|
|
|
|
ctrlKey: false,
|
|
|
|
|
metaKey: false,
|
|
|
|
|
altKey: false,
|
|
|
|
|
shiftKey: true,
|
|
|
|
|
onKeyUp: false,
|
|
|
|
|
onKeyDown: true,
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
action: 'set-ar-zoom',
|
|
|
|
|
label: '32:9',
|
|
|
|
|
comment: 'Zoom for 32:9 aspect ratio',
|
|
|
|
|
arguments: {
|
|
|
|
|
type: AspectRatioType.Fixed,
|
|
|
|
|
ratio: 3.56
|
|
|
|
|
},
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
const compareShortcuts = (a: any, b: any) => {
|
|
|
|
|
if (!a || !b) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return a.key === b.key && b.code === b.code && a.ctrlKey == b.ctrlKey && a.shiftKey == b.shiftKey && a.metaKey == a.metaKey && a.altKey == b.altKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hasConflict = (shortcut: any) => {
|
|
|
|
|
for (const ct in userOptions.commands) {
|
|
|
|
|
for (const command of userOptions.commands[ct]) {
|
|
|
|
|
if (compareShortcuts(shortcut, command.shortcut)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const zoomAction of newZoomActions) {
|
|
|
|
|
if (
|
|
|
|
|
!userOptions.commands.zoom.find(
|
|
|
|
|
x => x.action === zoomAction.action
|
|
|
|
|
&& x.arguments?.type === zoomAction.arguments?.type
|
|
|
|
|
&& x.arguments?.ratio === zoomAction.arguments?.ratio
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
userOptions.commands.zoom.push({
|
|
|
|
|
...zoomAction,
|
|
|
|
|
shortcut: hasConflict(zoomAction.shortcut) ? undefined : zoomAction.shortcut
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-20 16:11:17 +02:00
|
|
|
}
|
2025-08-03 02:37:05 +02:00
|
|
|
}, {
|
|
|
|
|
forVersion: '6.3.92',
|
2025-12-10 22:49:59 +01:00
|
|
|
updateFn: (userOptions: any) => {
|
2025-08-03 02:37:05 +02:00
|
|
|
// 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;
|
|
|
|
|
} else {
|
|
|
|
|
userOptions.sites[site].applyToEmbeddedContent = userOptions.sites[site].applyToEmbeddedContent ? EmbeddedContentSettingsOverridePolicy.Always : EmbeddedContentSettingsOverridePolicy.Never;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-08 19:35:12 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
forVersion: '6.3.93',
|
|
|
|
|
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface) => {
|
2025-10-14 18:52:22 +02:00
|
|
|
(userOptions as any).arDetect.polling = defaultOptions.aard.polling;
|
|
|
|
|
(userOptions as any).arDetect.subtitles = defaultOptions.aard.subtitles;
|
|
|
|
|
(userOptions as any).arDetect.autoDisable = defaultOptions.aard.autoDisable;
|
2025-10-08 19:35:12 +02:00
|
|
|
}
|
2025-10-12 22:03:55 +02:00
|
|
|
},
|
|
|
|
|
{
|
2025-10-14 18:52:22 +02:00
|
|
|
forVersion: '6.3.98',
|
2025-10-12 22:03:55 +02:00
|
|
|
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface) => {
|
2025-10-14 18:52:22 +02:00
|
|
|
(userOptions as any).arDetect.letterboxOrientationScan = defaultOptions.aard.letterboxOrientationScan;
|
|
|
|
|
(userOptions as any).arDetect.edgeDetection = defaultOptions.aard.edgeDetection;
|
|
|
|
|
(userOptions as any).arDetect.subtitles = defaultOptions.aard.subtitles;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
forVersion: '6.3.98',
|
2025-12-11 02:43:39 +01:00
|
|
|
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface) => {
|
2025-10-14 18:52:22 +02:00
|
|
|
userOptions.aard = defaultOptions.aard;
|
|
|
|
|
userOptions.aardLegacy = defaultOptions.aardLegacy;
|
|
|
|
|
delete (userOptions as any).arDetect;
|
2025-10-12 22:03:55 +02:00
|
|
|
}
|
2025-12-10 22:49:59 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
forVersion: '6.3.994',
|
2025-12-11 02:43:39 +01:00
|
|
|
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface, logger?) => {
|
2025-12-10 22:49:59 +01:00
|
|
|
const convertLegacyExtensionMode = (option: {normal: LegacyExtensionMode, theater: LegacyExtensionMode, fullscreen: LegacyExtensionMode}) => {
|
2025-12-11 02:43:39 +01:00
|
|
|
logger.log('updateFn', 'converting option', option);
|
2025-12-10 22:49:59 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-03 00:28:35 +02:00
|
|
|
}
|
2025-10-08 19:35:12 +02:00
|
|
|
|
2025-04-26 01:11:31 +02:00
|
|
|
]);
|
2019-07-05 23:45:29 +02:00
|
|
|
|
2019-11-02 01:05:36 +01:00
|
|
|
|
2021-10-28 22:53:23 +02:00
|
|
|
export default ExtensionConfPatch;
|