ultrawidify/src/ext/conf/ExtConfPatches.js

248 lines
6.5 KiB
JavaScript
Raw Normal View History

2019-07-05 23:45:29 +02:00
// How to use:
// version: {ExtensionConf object, but only properties that get overwritten}
2019-09-03 00:28:35 +02:00
const ExtensionConfPatch = [
{
forVersion: '4.2.0',
2019-07-05 23:45:29 +02:00
sites: {
"old.reddit.com" : {
type: 'testing',
DOM: {
player: {
manual: true,
useRelativeAncestor: false,
querySelectors: '.reddit-video-player-root, .media-preview-content'
2019-07-05 23:45:29 +02:00
}
},
css: '',
},
"www.reddit.com" : {
type: 'testing',
DOM: {
player: {
manual: true,
useRelativeAncestor: false,
querySelectors: '.reddit-video-player-root, .media-preview-content'
2019-07-05 23:45:29 +02:00
}
},
css: '',
},
"www.youtube.com" : {
DOM: {
player: {
manual: true,
querySelectors: "#movie_player, #player",
additionalCss: "",
useRelativeAncestor: false,
playerNodeCss: "",
}
}
},
}
2019-09-03 00:28:35 +02:00
}, {
forVersion: '4.2.3.1',
sites: {
"old.reddit.com" : {
type: 'testing',
DOM: {
player: {
manual: true,
useRelativeAncestor: false,
querySelectors: '.media-preview-content, .reddit-video-player-root'
}
},
css: '',
},
"www.reddit.com" : {
type: 'testing',
DOM: {
player: {
manual: true,
useRelativeAncestor: false,
querySelectors: '.media-preview-content, .reddit-video-player-root'
}
},
css: '',
},
"www.youtube.com" : {
DOM: {
player: {
manual: true,
querySelectors: "#movie_player, #player",
additionalCss: "",
useRelativeAncestor: false,
playerNodeCss: "",
}
}
},
}
}, {
forVersion: '4.3.0',
sites: {
"old.reddit.com" : {
type: 'testing',
DOM: {
player: {
2019-09-22 02:07:04 +02:00
manual: false,
2019-09-03 00:28:35 +02:00
useRelativeAncestor: false,
2019-09-22 02:07:04 +02:00
querySelectors: '.reddit-video-player-root, .media-preview-content'
2019-09-03 00:28:35 +02:00
}
},
2019-09-22 02:07:04 +02:00
css: 'video {\n width: 100% !important;\n height: 100% !important;\n}',
2019-09-03 00:28:35 +02:00
},
"www.reddit.com" : {
type: 'testing',
DOM: {
player: {
2019-09-22 02:07:04 +02:00
manual: false,
2019-09-03 00:28:35 +02:00
useRelativeAncestor: false,
2019-09-22 02:07:04 +02:00
querySelectors: '.reddit-video-player-root, .media-preview-content'
2019-09-03 00:28:35 +02:00
}
},
2019-09-22 02:07:04 +02:00
css: 'video {\n width: 100% !important;\n height: 100% !important;\n}',
2019-09-03 00:28:35 +02:00
},
}
2019-10-20 14:09:19 +02:00
}, {
2019-10-20 14:13:58 +02:00
forVersion: '4.3.1.1',
2019-10-20 14:09:19 +02:00
sites: {
2019-10-20 21:11:17 +02:00
'www.twitch.tv': {
2019-10-20 14:09:19 +02:00
DOM: {
player: {
manual: false,
querySelectors: "",
additionalCss: "",
useRelativeAncestor: false,
playerNodeCss: ""
}
}
}
}
2019-11-02 01:05:36 +01:00
}, {
forVersion: '4.4.0',
updateFn: (userOptions, defaultOptions) => {
// remove 'press P to toggle panning mode' thing
const togglePan = userOptions.actions.find(x => x.cmd && x.cmd.length === 1 && x.cmd[0].action === 'toggle-pan');
if (togglePan) {
togglePan.scopes = {};
}
// add new actions
userOptions.actions.push({
name: 'Don\'t persist crop',
label: 'Never persist',
cmd: [{
action: 'set-ar-persistence',
arg: 0,
}],
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: 1,
}],
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: 2,
}],
scopes: {
site: {
show: true,
},
global: {
show: true,
}
},
playerUi: {
show: true,
}
}, {
name: 'Persist until manually reset',
label: 'Always persist',
cmd: [{
action: 'set-ar-persistence',
arg: 3,
}],
scopes: {
site: {
show: true,
},
global: {
show: true,
}
},
playerUi: {
show: true,
}
}, {
name: 'Default crop persistence',
label: 'Default',
cmd: [{
action: 'set-ar-persistence',
arg: -1,
}],
scopes: {
site: {
show: true,
},
},
playerUi: {
show: true,
}
});
// patch shortcuts for non-latin layouts, but only if the user hasn't changed default keys
for (const action of userOptions.actions) {
if (!action.cmd || action.cmd.length !== 1) {
continue;
}
try {
// if this fails, then action doesn't have keyboard shortcut associated with it, so we skip it
const actionDefaults = defaultOptions.actions.find(x => x.cmd && x.cmd.length === 1 // (redundant, default actions have exactly 1 cmd in array)
&& x.cmd[0].action === action.cmd[0].action
&& x.scopes.page
&& x.scopes.page.shortcut
&& x.scopes.page.shortcut.length === 1
&& x.scopes.page.shortcut[0].key === action.scopes.page.shortcut[0].key // this can throw exception, and it's okay
);
if (actionDefaults === undefined) {
continue;
}
// update 'code' property for shortcut
action.scopes.page.shortcut[0]['code'] = actionDefaults.scopes.page.shortcut[0].code;
} catch (e) {
continue;
}
}
}
2019-09-03 00:28:35 +02:00
}
];
2019-07-05 23:45:29 +02:00
2019-11-02 01:05:36 +01:00
2019-07-05 23:45:29 +02:00
export default ExtensionConfPatch;