Compare commits
2 Commits
39f39f23a7
...
5f3562fe5b
Author | SHA1 | Date | |
---|---|---|---|
5f3562fe5b | |||
0d7c535a70 |
@ -245,33 +245,6 @@ interface SettingsInterface {
|
||||
limit?: number,
|
||||
}
|
||||
}
|
||||
// -----------------------------------------
|
||||
// ::: ACTIONS :::
|
||||
// -----------------------------------------
|
||||
// Nastavitve za ukaze. Zamenja stare nastavitve za bližnične tipke.
|
||||
//
|
||||
// Polje 'shortcut' je tabela, če se slučajno lotimo kdaj delati choordov.
|
||||
actions: {
|
||||
name?: string, // name displayed in settings
|
||||
label?: string, // name displayed in ui (can be overridden in scope/playerUi)
|
||||
cmd?: {
|
||||
action: string,
|
||||
arg: any,
|
||||
customArg?: any,
|
||||
persistent?: boolean, // optional, false by default. If true, change doesn't take effect immediately.
|
||||
// Instead, this action saves stuff to settings
|
||||
}[],
|
||||
scopes?: {
|
||||
global?: ActionScopeInterface,
|
||||
site?: ActionScopeInterface,
|
||||
page?: ActionScopeInterface
|
||||
},
|
||||
playerUi?: {
|
||||
show: boolean,
|
||||
path?: string,
|
||||
},
|
||||
userAdded?: boolean,
|
||||
}[],
|
||||
// This object fulfills the same purpose as 'actions', but is written in less retarded and overly
|
||||
// complicated way. Hopefully it'll be easier to maintain it that way.
|
||||
commands?: {
|
||||
|
@ -8,201 +8,10 @@ import SettingsInterface from '../../common/interfaces/SettingsInterface';
|
||||
import { _cp } from '../../common/js/utils';
|
||||
import CropModePersistence from '../../common/enums/CropModePersistence.enum';
|
||||
import AspectRatioType from '../../common/enums/AspectRatioType.enum';
|
||||
import { update } from 'lodash';
|
||||
|
||||
const ExtensionConfPatch = [
|
||||
{
|
||||
forVersion: '6.1.1',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
// add new commands
|
||||
userOptions.commands = defaultOptions.commands;
|
||||
userOptions.actions = defaultOptions.actions;
|
||||
}
|
||||
}, {
|
||||
// NOTE - when releasing shit, ensure ALL alpha migrations are combined together in one function
|
||||
forVersion: '6.1.2',
|
||||
updateFn: (userOptions, defaultOptions) => {
|
||||
userOptions.commands = defaultOptions.commands;
|
||||
|
||||
// migrates old settings regarding whether extension is enabled or not
|
||||
const copyEnabled = (site) => {
|
||||
userOptions.sites[site].enable = {
|
||||
fullscreen: userOptions.sites[site].mode,
|
||||
theater: userOptions.sites[site].mode,
|
||||
normal: ExtensionMode.Disabled
|
||||
};
|
||||
userOptions.sites[site].enableKeyboard = {
|
||||
fullscreen: userOptions.sites[site].keyboardShortcutsEnabled,
|
||||
theater: userOptions.sites[site].keyboardShortcutsEnabled,
|
||||
normal: ExtensionMode.Disabled
|
||||
};
|
||||
userOptions.sites[site].enableAard = {
|
||||
fullscreen: userOptions.sites[site].autoar,
|
||||
theater: userOptions.sites[site].autoar,
|
||||
normal: ExtensionMode.Disabled
|
||||
};
|
||||
|
||||
userOptions.sites[site].stretchModePersistence = userOptions.sites[site].cropModePersistence;
|
||||
|
||||
// remove old options
|
||||
delete userOptions.sites[site].mode;
|
||||
delete userOptions.sites[site].keyboardShortcutsEnabled;
|
||||
delete userOptions.sites[site].autoar;
|
||||
}
|
||||
|
||||
// globals get carried over before other sites:
|
||||
copyEnabled('@global');
|
||||
|
||||
// we make another guess about a new option we just added
|
||||
|
||||
|
||||
for (const key in userOptions.sites) {
|
||||
// we already had this
|
||||
if (key === '@global') {
|
||||
continue;
|
||||
}
|
||||
|
||||
copyEnabled(key);
|
||||
|
||||
userOptions.sites[key].DOMConfig = _cp(defaultOptions.sites[key].DOMConfig)
|
||||
|
||||
// convert old site.DOM to site.DOMConfig[]
|
||||
if (userOptions.sites[key].type === 'user-defined') {
|
||||
const DOM = userOptions.sites[key].DOM;
|
||||
if (DOM) {
|
||||
userOptions.sites[key].DOMConfig['user-defined'] = {
|
||||
type: 'user-1',
|
||||
customCss: DOM?.css,
|
||||
periodicallyRefreshPlayerElement: DOM?.player?.periodicallyRefreshPlayerElement,
|
||||
elements: !(DOM?.player) ? undefined : {
|
||||
player: {
|
||||
manual: DOM?.player?.manual,
|
||||
querySelectors: DOM?.player?.useRelativeAncestor ? undefined : DOM?.player?.querySelectors,
|
||||
index: DOM?.player?.useRelativeAncestor ? DOM?.player?.videoAncestor : undefined,
|
||||
}
|
||||
}
|
||||
}
|
||||
userOptions.sites[key].activeDOMConfig = 'user-1';
|
||||
|
||||
// remove old configuration
|
||||
delete userOptions.sites[key].DOM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.0.3',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
delete (userOptions as any).sites['@global'].persistOption;
|
||||
delete (userOptions as any).sites['@empty'].persistOption;
|
||||
|
||||
userOptions.sites['@global'].persistCSA = CropModePersistence.Disabled;
|
||||
userOptions.sites['@empty'].persistCSA = CropModePersistence.Disabled;
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.0.4',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
|
||||
// deprecated much?
|
||||
userOptions.actions.push({
|
||||
name: 'Cycle aspect ratio',
|
||||
label: 'Cycle',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Cycle
|
||||
}]
|
||||
});
|
||||
// userOptions.commands.crop.push({
|
||||
// action: 'set-ar',
|
||||
// label: 'Cycle',
|
||||
// comment: 'Cycle through crop options',
|
||||
// arguments: {
|
||||
// type: AspectRatioType.Cycle
|
||||
// },
|
||||
// shortcut: {
|
||||
// key: 'c',
|
||||
// code: 'KeyC',
|
||||
// ctrlKey: false,
|
||||
// metaKey: false,
|
||||
// altKey: false,
|
||||
// shiftKey: false,
|
||||
// onKeyUp: true,
|
||||
// onKeyDown: false,
|
||||
// }
|
||||
// });
|
||||
// userOptions.commands.crop.push({
|
||||
// action: 'set-ar',
|
||||
// label: '32:9',
|
||||
// comment: 'Crop for 32:9 aspect ratio',
|
||||
// arguments: {
|
||||
// type: AspectRatioType.Fixed,
|
||||
// ratio: 3.56
|
||||
// },
|
||||
// })
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.1.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};
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.1.1-6',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
for (const site in userOptions.sites) {
|
||||
userOptions.sites[site].defaultType = userOptions.sites[site].type as any;
|
||||
}
|
||||
userOptions.sites['@global'].defaultType = 'unknown';
|
||||
userOptions.sites['@empty'].defaultType = 'modified';
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.1.2-0',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
// remove custom CSS, as it is no longer needed
|
||||
for (const site in userOptions.sites) {
|
||||
for (const domOption in userOptions.sites[site].DOMConfig)
|
||||
userOptions.sites[site].DOMConfig[domOption].customCss;
|
||||
}
|
||||
userOptions.arDetect.aardType = 'auto';
|
||||
userOptions.ui = {
|
||||
inPlayer: {
|
||||
enabled: true, // enable by default on new installs
|
||||
enabledFullscreenOnly: false,
|
||||
minEnabledWidth: 0.75,
|
||||
minEnabledHeight: 0.75,
|
||||
activation: 'player',
|
||||
popupAlignment: 'left',
|
||||
triggerZoneDimensions: {
|
||||
width: 0.5,
|
||||
height: 0.5,
|
||||
offsetX: -50,
|
||||
offsetY: 0,
|
||||
}
|
||||
}
|
||||
},
|
||||
userOptions.newFeatureTracker['uw6.ui-popup'] = {show: 10};
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.2.1',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
userOptions.ui = defaultOptions.ui;
|
||||
userOptions.arDetect = defaultOptions.arDetect;
|
||||
userOptions.newFeatureTracker = defaultOptions.newFeatureTracker;
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.2.3',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
for (const site in userOptions.sites) {
|
||||
if (userOptions.sites[site].defaults?.stretch && !userOptions.sites[site].defaults?.stretch.type) {
|
||||
userOptions.sites[site].defaults.stretch = {type: userOptions.sites[site].defaults?.stretch as any as StretchType};
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.2.4',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
for (const site in userOptions.sites) {
|
||||
@ -224,6 +33,57 @@ const ExtensionConfPatch = [
|
||||
normal: ExtensionMode.Default,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.2.6',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions) => {
|
||||
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;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -354,9 +354,9 @@ const ExtensionConf: SettingsInterface = {
|
||||
}],
|
||||
zoom: [{
|
||||
action: 'change-zoom',
|
||||
label: 'Zoom +10%',
|
||||
label: 'Zoom +5%',
|
||||
arguments: {
|
||||
zoom: 0.1
|
||||
zoom: 0.05
|
||||
},
|
||||
shortcut: {
|
||||
key: 'z',
|
||||
@ -372,9 +372,9 @@ const ExtensionConf: SettingsInterface = {
|
||||
actionId: 'change-zoom-10in'
|
||||
}, {
|
||||
action: 'change-zoom',
|
||||
label: 'Zoom -10%',
|
||||
label: 'Zoom -5%',
|
||||
arguments: {
|
||||
zoom: -0.1
|
||||
zoom: -0.05
|
||||
},
|
||||
shortcut: {
|
||||
key: 'u',
|
||||
@ -577,803 +577,6 @@ const ExtensionConf: SettingsInterface = {
|
||||
internalOnly: true
|
||||
}]
|
||||
},
|
||||
// -----------------------------------------
|
||||
// ::: ACTIONS :::
|
||||
// -----------------------------------------
|
||||
actions: [{
|
||||
name: 'Trigger automatic detection', // name displayed in settings
|
||||
label: 'Automatic', // name displayed in ui (can be overridden in scope/playerUi)
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Automatic,
|
||||
persistent: false, // optional, false by default. If true, change doesn't take effect immediately.
|
||||
// Instead, this action saves stuff to settings
|
||||
}],
|
||||
scopes: {
|
||||
global: { // if 'global' is undefined, 'show' is presumed to be 'false'
|
||||
show: false,
|
||||
},
|
||||
site: {
|
||||
show: false,
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
label: 'Automatic', // example override, takes precedence over default label
|
||||
shortcut: [{
|
||||
key: 'a',
|
||||
code: 'KeyA',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}],
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop',
|
||||
},
|
||||
}, {
|
||||
name: 'Reset to default',
|
||||
label: 'Reset',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Reset,
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
shortcut: [{
|
||||
key: 'r',
|
||||
code: 'KeyR',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}],
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
},
|
||||
}, {
|
||||
name: 'Fit to width',
|
||||
label: 'Fit width',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.FitWidth,
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
shortcut: [{
|
||||
key: 'w',
|
||||
code: 'KeyW',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}],
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
}
|
||||
}, {
|
||||
name: 'Fit to height',
|
||||
label: 'Fit height',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.FitHeight
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
shortcut: [{
|
||||
key: 'e',
|
||||
code: 'KeyE',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}]
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
}
|
||||
}, {
|
||||
name: 'Cycle aspect ratio',
|
||||
label: 'Cycle',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Cycle
|
||||
}]
|
||||
},{
|
||||
userAdded: true,
|
||||
name: 'Set aspect ratio to 16:9',
|
||||
label: '16:9',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Fixed,
|
||||
customArg: 1.78,
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
shortcut: [{
|
||||
key: 's',
|
||||
code: 'KeyS',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: false,
|
||||
onKeyDown: true,
|
||||
}],
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
}
|
||||
}, {
|
||||
userAdded: true,
|
||||
name: 'Set aspect ratio to 21:9 (2.39:1)',
|
||||
label: '21:9',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Fixed,
|
||||
customArg: 2.39
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
shortcut: [{
|
||||
key: 'd',
|
||||
code: 'KeyD',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: false,
|
||||
onKeyDown: true,
|
||||
}]
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
}
|
||||
}, {
|
||||
userAdded: true,
|
||||
name: 'Set aspect ratio to 18:9',
|
||||
label: '18:9',
|
||||
cmd: [{
|
||||
action: 'set-ar',
|
||||
arg: AspectRatioType.Fixed,
|
||||
customArg: 2.0,
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
shortcut: [{
|
||||
key: 'x',
|
||||
code: 'KeyX',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}]
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop',
|
||||
}
|
||||
}, {
|
||||
name: 'Don\'t persist crop',
|
||||
label: 'Never persist',
|
||||
cmd: [{
|
||||
action: 'set-ar-persistence',
|
||||
arg: CropModePersistence.Disabled,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
global: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
}
|
||||
}, {
|
||||
name: 'Persist crop while on page',
|
||||
label: 'Until page load',
|
||||
cmd: [{
|
||||
action: 'set-ar-persistence',
|
||||
arg: CropModePersistence.UntilPageReload,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
global: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
}
|
||||
}, {
|
||||
name: 'Persist crop for current session',
|
||||
label: 'Current session',
|
||||
cmd: [{
|
||||
action: 'set-ar-persistence',
|
||||
arg: CropModePersistence.CurrentSession,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
global: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
}
|
||||
}, {
|
||||
name: 'Persist until manually reset',
|
||||
label: 'Always persist',
|
||||
cmd: [{
|
||||
action: 'set-ar-persistence',
|
||||
arg: CropModePersistence.Forever,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
global: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
}
|
||||
}, {
|
||||
name: 'Default crop persistence',
|
||||
label: 'Default',
|
||||
cmd: [{
|
||||
action: 'set-ar-persistence',
|
||||
arg: CropModePersistence.Default,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
}
|
||||
}, {
|
||||
name: 'Zoom in',
|
||||
label: 'Zoom',
|
||||
cmd: [{
|
||||
action: 'change-zoom',
|
||||
arg: 0.1
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: false,
|
||||
shortcut: [{
|
||||
key: 'z',
|
||||
code: 'KeyY',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}],
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: false,
|
||||
}
|
||||
}, {
|
||||
name: 'Zoom out',
|
||||
label: 'Unzoom',
|
||||
cmd: [{
|
||||
action: 'change-zoom',
|
||||
arg: -0.1
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: false,
|
||||
shortcut: [{
|
||||
key: 'u',
|
||||
code: 'KeyU',
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
onKeyUp: true,
|
||||
onKeyDown: false,
|
||||
}],
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: false
|
||||
}
|
||||
}, {
|
||||
name: 'Toggle panning mode',
|
||||
label: 'Toggle pan',
|
||||
cmd: [{
|
||||
action: 'toggle-pan',
|
||||
arg: 'toggle'
|
||||
}],
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'zoom'
|
||||
},
|
||||
scopes: {
|
||||
}
|
||||
}, {
|
||||
name: 'Hold to pan',
|
||||
cmd: [{
|
||||
action: 'pan',
|
||||
arg: 'toggle',
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: false,
|
||||
shortcut: [{
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
shiftKey: true,
|
||||
onKeyDown: false,
|
||||
onKeyUp: false,
|
||||
onMouseMove: true,
|
||||
}],
|
||||
}
|
||||
}
|
||||
},
|
||||
//
|
||||
// S T R E T C H I N G
|
||||
//
|
||||
{
|
||||
name: 'Set stretch to "none"',
|
||||
label: 'Don\'t stretch',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.NoStretch,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
label: 'Normal'
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
label: 'Normal'
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
label: 'Normal'
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'stretch'
|
||||
}
|
||||
}, {
|
||||
name: 'Set stretch to "basic"',
|
||||
label: 'Basic stretch',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.Basic,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
label: 'Basic'
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
label: 'Basic'
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
label: 'Basic'
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'stretch'
|
||||
}
|
||||
}, {
|
||||
name: 'Set stretch to "hybrid"',
|
||||
label: 'Hybrid stretch',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.Hybrid,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
label: 'Hybrid'
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
label: 'Hybrid'
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
label: 'Hybrid'
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'stretch'
|
||||
}
|
||||
}, {
|
||||
name: 'Stretch only to hide thin borders',
|
||||
label: 'Thin borders only',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.Conditional,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
label: 'Thin borders'
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
label: 'Thin borders'
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
label: 'Thin borders'
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'stretch'
|
||||
}
|
||||
}, {
|
||||
name: 'Set stretch to default value',
|
||||
label: 'Default',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.Default,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Stretch source to 4:3',
|
||||
label: '4:3 stretch (src)',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.FixedSource,
|
||||
customArg: 1.33,
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
}
|
||||
}, {
|
||||
name: 'Stretch source to 16:9',
|
||||
label: '16:9 stretch (src)',
|
||||
cmd: [{
|
||||
action: 'set-stretch',
|
||||
arg: StretchType.FixedSource,
|
||||
customArg: 1.77,
|
||||
}],
|
||||
scopes: {
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'crop'
|
||||
}
|
||||
},
|
||||
//
|
||||
// A L I G N M E N T
|
||||
//
|
||||
{
|
||||
name: 'Align video to the left',
|
||||
label: 'Left',
|
||||
cmd: [{
|
||||
action: 'set-alignment',
|
||||
arg: VideoAlignmentType.Left,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'align'
|
||||
}
|
||||
}, {
|
||||
name: 'Align video to center',
|
||||
label: 'Center',
|
||||
cmd: [{
|
||||
action: 'set-alignment',
|
||||
arg: VideoAlignmentType.Center,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'align'
|
||||
}
|
||||
}, {
|
||||
name: 'Align video to the right',
|
||||
label: 'Right',
|
||||
cmd: [{
|
||||
action: 'set-alignment',
|
||||
arg: VideoAlignmentType.Right
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
},
|
||||
playerUi: {
|
||||
show: true,
|
||||
path: 'align'
|
||||
}
|
||||
}, {
|
||||
name: 'Use default alignment',
|
||||
label: 'Default',
|
||||
cmd: [{
|
||||
action: 'set-alignment',
|
||||
arg: VideoAlignmentType.Default
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
//
|
||||
// E N A B L E E X T E N S I O N / A U T O A R
|
||||
// (for sites/extension tab in the popup)
|
||||
//
|
||||
{
|
||||
name: 'Enable extension',
|
||||
label: 'Enable',
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: ExtensionMode.Enabled,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Enable extension on whitelisted sites only',
|
||||
label: 'On whitelist only',
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: ExtensionMode.Whitelist,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Extension mode: use default settings',
|
||||
label: 'Default',
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: ExtensionMode.Default,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Disable extension',
|
||||
label: 'Disable',
|
||||
cmd: [{
|
||||
action: 'set-extension-mode',
|
||||
arg: ExtensionMode.Disabled,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Enable automatic aspect ratio detection',
|
||||
label: 'Enable',
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: ExtensionMode.Enabled,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true
|
||||
},
|
||||
site: {
|
||||
show: true
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Enable automatic aspect ratio detection on whitelisted sites only',
|
||||
label: 'On whitelist only',
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: ExtensionMode.Whitelist,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Use default settings for automatic aspect ratio detection',
|
||||
label: 'Default',
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: ExtensionMode.Default,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Disable automatic aspect ratio detection',
|
||||
label: 'Disable',
|
||||
cmd: [{
|
||||
action: 'set-autoar-mode',
|
||||
arg: ExtensionMode.Disabled,
|
||||
persistent: true,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
//
|
||||
//
|
||||
// Enable/disable keyboard shortcuts
|
||||
//
|
||||
{
|
||||
name: 'Enable keyboard shortcuts',
|
||||
label: 'Enable',
|
||||
cmd: [{
|
||||
action: 'set-keyboard',
|
||||
arg: ExtensionMode.Enabled,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Enable keyboard shortcuts on whitelisted sites only',
|
||||
label: 'On whitelist only',
|
||||
cmd: [{
|
||||
action: 'set-keyboard',
|
||||
arg: ExtensionMode.Whitelist,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true
|
||||
},
|
||||
}
|
||||
}, {
|
||||
name: 'Keyboard shortcuts mode: use default settings',
|
||||
label: 'Default',
|
||||
cmd: [{
|
||||
action: 'set-keyboard',
|
||||
arg: ExtensionMode.Default,
|
||||
}],
|
||||
scopes: {
|
||||
site: {
|
||||
show: true
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'Disable keyboard shortcuts',
|
||||
label: 'Disable',
|
||||
cmd: [{
|
||||
action: 'set-keyboard',
|
||||
arg: ExtensionMode.Disabled,
|
||||
}],
|
||||
scopes: {
|
||||
global: {
|
||||
show: true,
|
||||
},
|
||||
site: {
|
||||
show: true,
|
||||
},
|
||||
page: {
|
||||
show: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
mitigations: {
|
||||
zoomLimit: {
|
||||
enabled: true,
|
||||
|
@ -39,6 +39,8 @@ class Settings {
|
||||
|
||||
onChangedCallbacks: (() => void)[] = [];
|
||||
afterSettingsChangedCallbacks: (() => void)[] = [];
|
||||
|
||||
private sortedPatches: any[];
|
||||
//#endregion
|
||||
|
||||
constructor(options) {
|
||||
@ -51,6 +53,8 @@ class Settings {
|
||||
this.default['version'] = this.getExtensionVersion();
|
||||
|
||||
chrome.storage.onChanged.addListener((changes, area) => {this.storageChangeListener(changes, area)});
|
||||
|
||||
this.sortedPatches = this.sortConfPatches(ExtensionConfPatch);
|
||||
}
|
||||
|
||||
private storageChangeListener(changes, area) {
|
||||
@ -171,12 +175,11 @@ class Settings {
|
||||
return patchesIn.sort( (a, b) => this.compareExtensionVersions(a.forVersion, b.forVersion));
|
||||
}
|
||||
|
||||
private findFirstNecessaryPatch(version, extconfPatches) {
|
||||
const sorted = this.sortConfPatches(extconfPatches);
|
||||
return sorted.findIndex(x => this.compareExtensionVersions(x.forVersion, version) > 0);
|
||||
private findFirstNecessaryPatch(version) {
|
||||
return this.sortedPatches.findIndex(x => this.compareExtensionVersions(x.forVersion, version) > 0);
|
||||
}
|
||||
private applySettingsPatches(oldVersion, patches) {
|
||||
let index = this.findFirstNecessaryPatch(oldVersion, patches);
|
||||
private applySettingsPatches(oldVersion) {
|
||||
let index = this.findFirstNecessaryPatch(oldVersion);
|
||||
|
||||
if (index === -1) {
|
||||
this.logger?.log('info','settings','[Settings::applySettingsPatches] There are no pending conf patches.');
|
||||
@ -184,17 +187,16 @@ class Settings {
|
||||
}
|
||||
|
||||
// apply all remaining patches
|
||||
this.logger?.log('info', 'settings', `[Settings::applySettingsPatches] There are ${patches.length - index} settings patches to apply`);
|
||||
while (index < patches.length) {
|
||||
const updateFn = patches[index].updateFn;
|
||||
delete patches[index].forVersion;
|
||||
delete patches[index].updateFn;
|
||||
this.logger?.log('info', 'settings', `[Settings::applySettingsPatches] There are ${this.sortedPatches.length - index} settings patches to apply`);
|
||||
while (index < this.sortedPatches.length) {
|
||||
const updateFn = this.sortedPatches[index].updateFn;
|
||||
delete this.sortedPatches[index].forVersion;
|
||||
delete this.sortedPatches[index].updateFn;
|
||||
|
||||
if (Object.keys(patches[index]).length > 0) {
|
||||
ObjectCopy.overwrite(this.active, patches[index]);
|
||||
if (Object.keys( this.sortedPatches[index]).length > 0) {
|
||||
ObjectCopy.overwrite(this.active, this.sortedPatches[index]);
|
||||
}
|
||||
if (updateFn) {
|
||||
|
||||
try {
|
||||
updateFn(this.active, this.getDefaultSettings());
|
||||
} catch (e) {
|
||||
@ -222,15 +224,6 @@ class Settings {
|
||||
);
|
||||
}
|
||||
|
||||
// if (Debug.flushStoredSettings) {
|
||||
// this.logger?.log('info', 'settings', "%c[Settings::init] Debug.flushStoredSettings is true. Using default settings", "background: #d00; color: #ffd");
|
||||
// Debug.flushStoredSettings = false; // don't do it again this session
|
||||
// this.active = this.getDefaultSettings();
|
||||
// this.active.version = this.version;
|
||||
// this.set(this.active);
|
||||
// return this.active;
|
||||
// }
|
||||
|
||||
// if there's no settings saved, return default settings.
|
||||
if(! settings || (Object.keys(settings).length === 0 && settings.constructor === Object)) {
|
||||
this.logger?.log(
|
||||
@ -278,7 +271,7 @@ class Settings {
|
||||
}
|
||||
|
||||
// in case settings in previous version contained a fucky wucky, we overwrite existing settings with a patch
|
||||
this.applySettingsPatches(oldVersion, ExtensionConfPatch);
|
||||
this.applySettingsPatches(oldVersion);
|
||||
|
||||
// set 'whatsNewChecked' flag to false when updating, always
|
||||
this.active.whatsNewChecked = false;
|
||||
|
@ -54,6 +54,10 @@ export class KeyboardHandler extends KbmBase {
|
||||
init() {
|
||||
this.logger.log('info', 'debug', "[KeyboardHandler::init] starting init");
|
||||
|
||||
// reset keypressActions when re-initializing, otherwise keypressActions will
|
||||
// multiply in an unwanted way
|
||||
this.keypressActions = [];
|
||||
|
||||
// build the action list — but only from actions that have shortcuts assigned
|
||||
for (const key in this.settings.active.commands) {
|
||||
for (const command of this.settings.active.commands[key]) {
|
||||
@ -224,7 +228,6 @@ export class KeyboardHandler extends KbmBase {
|
||||
this.logger.log('info', 'keyboard', "%c[KeyboardHandler::handleKeyup] Trying to find and execute action for event. Actions/event: ", "color: #ff0", this.keypressActions, event);
|
||||
|
||||
const isLatin = this.isLatin(event.key);
|
||||
|
||||
for (const command of this.keypressActions) {
|
||||
if (this.isActionMatch(command.shortcut, event, isLatin)) {
|
||||
this.eventBus.send(command.action, command.arguments);
|
||||
|
@ -121,7 +121,7 @@ class Resizer {
|
||||
function: (config: any) => this.setZoom(config.zoom, config.axis, config.noAnnounce)
|
||||
}],
|
||||
'change-zoom': [{
|
||||
function: (config: any) => this.zoomStep(config.step)
|
||||
function: (config: any) => this.zoomStep(config.zoom)
|
||||
}],
|
||||
'get-ar': [{
|
||||
function: () => this.eventBus.send('uw-config-broadcast', {type: 'ar', config: this.lastAr})
|
||||
@ -697,7 +697,7 @@ class Resizer {
|
||||
|
||||
private _computeOffsetsRecursionGuard: boolean = false;
|
||||
computeOffsets(stretchFactors: VideoDimensions, ar?: Ar){
|
||||
this.logger.log('info', 'debug', "[Resizer::computeOffsets] <rid:"+this.resizerId+"> video will be aligned to ", this.videoAlignment);
|
||||
this.logger.log('info', 'debug', "[Resizer::computeOffsets] <rid:"+this.resizerId+"> video will be aligned to ", this.videoAlignment, '— stretch factors before processing:', stretchFactors);
|
||||
|
||||
const {realVideoWidth, realVideoHeight, marginX, marginY} = this.computeVideoDisplayedDimensions();
|
||||
|
||||
|
@ -40,28 +40,29 @@ class Zoom {
|
||||
* Increases zoom by a given amount. Does not allow per-axis zoom.
|
||||
* Will set zoom level to x axis (+ given amount) if x and y zooms differ.
|
||||
* @param amount
|
||||
* @param axis — leave undefined to apply zoom to both axes
|
||||
*/
|
||||
zoomStep(amount){
|
||||
this.logScale += amount;
|
||||
zoomStep(amount: number, axis?: 'x' | 'y') {
|
||||
let newLog = axis === 'y' ? this.logScaleY : this.logScale;
|
||||
newLog += amount;
|
||||
newLog = Math.min(Math.max(newLog, this.minScale), this.maxScale);
|
||||
|
||||
if (this.logScale <= this.minScale) {
|
||||
this.logScale = this.minScale;
|
||||
// if axis is undefined, both of this statements should trigger)
|
||||
if (axis !== 'y') {
|
||||
this.logScale = newLog;
|
||||
}
|
||||
if (this.logScale >= this.maxScale) {
|
||||
this.logScale = this.maxScale;
|
||||
if (axis !== 'x') {
|
||||
this.logScaleY = newLog;
|
||||
}
|
||||
|
||||
this.logScaleY = this.logScale;
|
||||
|
||||
this.scale = Math.pow(2, this.logScale);
|
||||
this.scaleY = Math.pow(2, this.logScaleY);
|
||||
|
||||
this.logger.log('info', 'debug', "[Zoom::zoomStep] changing zoom by", amount, ". New zoom level:", this.scale);
|
||||
this.processZoom();
|
||||
}
|
||||
|
||||
setZoom(scale: number, axis?: 'x' |'y', noAnnounce?){
|
||||
this.logger.log('info', 'debug', "[Zoom::setZoom] Setting zoom to", scale, "!");
|
||||
|
||||
// NOTE: SCALE IS NOT LOGARITHMIC
|
||||
if(scale < Math.pow(2, this.minScale)) {
|
||||
scale = this.minScale;
|
||||
@ -85,8 +86,7 @@ class Zoom {
|
||||
}
|
||||
|
||||
processZoom() {
|
||||
// this.conf.resizer.toFixedAr();
|
||||
|
||||
this.conf.resizer.toFixedAr();
|
||||
this.conf.resizer.applyScaling({xFactor: this.scale, yFactor: this.scaleY}, {noAnnounce: true});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user