-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
defaultSettings.ts
249 lines (227 loc) · 8.3 KB
/
defaultSettings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/**
* @license
* Copyright (C) 2021, 2022 WofWca <wofwca@protonmail.com>
*
* This file is part of Jump Cutter Browser Extension.
*
* Jump Cutter Browser Extension is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Jump Cutter Browser Extension is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Jump Cutter Browser Extension. If not, see <https://www.gnu.org/licenses/>.
*/
import { enabledSettingDefaultValue } from './';
import type { Settings } from './';
import { ControllerKind } from './ControllerKind';
import { HotkeyAction } from '@/hotkeys';
import { getGeckoLikelyMaxNonMutedPlaybackRate } from '@/helpers';
const stretchingControllerSpecificDefaults = {
marginBefore: 0,
marginAfter: 0.100,
} as const;
export const defaultSettings: Readonly<Settings> = {
volumeThreshold: 0.005,
previousVolumeThreshold: 0.005,
silenceSpeedSpecificationMethod: 'relativeToSoundedSpeed',
silenceSpeedRaw: 2.5,
previousSilenceSpeedRaw: 2.5,
// Argument for `soundedSpeed !== 1`:
// * It reminds the user that the extension is enabled, so he's not confused by media getting seeked seemingly
// randomly.
// * It shows the user that there is such functionality.
// * People who have installed this extension are expected to prefer a faster `soundedSpeed`.
// Arguments agains:
// * At a first glance you may think that if videos are being playing at a faster speed then it means
// that the extension thinks that the whole video is silent and is trying to skip silence this way.
// * It's better to start simple and not force the user to go to settings if they don't like
// `soundedSpeed !== 1`.
soundedSpeed: 1,
previousSoundedSpeed: 1,
enabled: enabledSettingDefaultValue,
// Seems like new users get immediately scared by the sound distortion the extension causes, so let's let users
// enable marginBefore manually IF they start noticing that they need it.
marginBefore: stretchingControllerSpecificDefaults.marginBefore,
previousMarginBefore: stretchingControllerSpecificDefaults.marginBefore,
marginAfter: stretchingControllerSpecificDefaults.marginAfter,
previousMarginAfter: stretchingControllerSpecificDefaults.marginAfter,
experimentalControllerType: ControllerKind.STRETCHING,
useSeparateMarginSettingsForDifferentAlgorithms: true,
algorithmSpecificSettings: {
[ControllerKind.CLONING]: {
marginBefore: 0.050,
marginAfter: 0.030,
},
[ControllerKind.STRETCHING]: {
...stretchingControllerSpecificDefaults,
},
},
applyTo: 'videoOnly',
omitMutedElements: true,
dontAttachToCrossOriginMedia: true,
enableHotkeys: true,
// TODO some code here is pretty WET, like duplicate hotkeys. DRY?
hotkeys: [
// Rewind/advance +
{
keyCombination: { code: 'KeyX', },
action: HotkeyAction.REWIND,
actionArgument: 5,
},
{
keyCombination: { code: 'KeyC', },
overrideWebsiteHotkeys: true, // Because on YouTube "C" toggles subtitles.
action: HotkeyAction.ADVANCE,
actionArgument: 5,
},
// soundedSpeed
{
keyCombination: { code: 'KeyS', },
action: HotkeyAction.DECREASE_SOUNDED_SPEED,
actionArgument: 0.25,
},
{
keyCombination: { code: 'KeyD', },
action: HotkeyAction.INCREASE_SOUNDED_SPEED,
actionArgument: 0.25,
},
{
keyCombination: { code: 'KeyA', },
action: HotkeyAction.TOGGLE_SOUNDED_SPEED,
actionArgument: 1,
},
// silenceSpeed
{
keyCombination: { code: 'KeyS', modifiers: ['shiftKey'], },
action: HotkeyAction.DECREASE_SILENCE_SPEED,
actionArgument: 0.25,
},
{
keyCombination: { code: 'KeyD', modifiers: ['shiftKey'], },
action: HotkeyAction.INCREASE_SILENCE_SPEED,
actionArgument: 0.25,
},
{
keyCombination: { code: 'KeyA', modifiers: ['shiftKey'], },
action: HotkeyAction.TOGGLE_SILENCE_SPEED,
actionArgument: 2.5,
},
// volumeThreshold
{
keyCombination: { code: 'KeyW', },
action: HotkeyAction.DECREASE_VOLUME_THRESHOLD,
actionArgument: 0.001,
},
{
keyCombination: { code: 'KeyE', },
action: HotkeyAction.INCREASE_VOLUME_THRESHOLD,
actionArgument: 0.001,
},
{
keyCombination: { code: 'KeyQ', },
action: HotkeyAction.TOGGLE_VOLUME_THRESHOLD,
actionArgument: 0,
},
{
keyCombination: { code: 'KeyW', modifiers: ['shiftKey'], },
action: HotkeyAction.DECREASE_VOLUME_THRESHOLD,
actionArgument: 0.010,
},
{
keyCombination: { code: 'KeyE', modifiers: ['shiftKey'], },
action: HotkeyAction.INCREASE_VOLUME_THRESHOLD,
actionArgument: 0.010,
},
// In case you coulnd't make it out. Practically turns on/off the extension. Why not actually turn it on/off?
// Because
// * We don't have such a hotkey action yet.
// * Hotkeys would also cease to work if we'd disable it.
// * It would create an audio glitch (at best), at worst it would remove/add audio delay (becaouse of how
// marginBefore) works.
// * It's computationally heavy.
// TODO these problems sound like then can be solved.
{
keyCombination: { code: 'KeyZ', },
action: HotkeyAction.TOGGLE_VOLUME_THRESHOLD,
actionArgument: 0,
},
{
keyCombination: { code: 'KeyZ', },
action: HotkeyAction.SET_SOUNDED_SPEED,
actionArgument: 1,
},
],
popupDisableHotkeysWhileInputFocused: true,
popupAutofocusEnabledInput: false,
popupChartWidthPx: 400,
popupChartHeightPx: 75,
popupChartLengthInSeconds: 8,
// TODO maybe even if `popupChartSpeed === 'intrinsicTime'` the period still should be in real time?
// At least as an option? But we're now expressing it as a fraction of chart length.
popupChartJumpPeriod: 0,
popupChartSpeed: 'soundedSpeedTime',
popupAlwaysShowOpenLocalFileLink: true,
// Remember that "step" also controls what the input does when you control it with the keyboard,
// aside from the mouse.
popupVolumeThresholdMin: 0,
popupVolumeThresholdMax: 0.050,
popupVolumeThresholdStep: 0.0001,
popupSoundedSpeedMin: 0.25,
popupSoundedSpeedMax: 4, // BUILD_DEFINITIONS.BROWSER === 'gecko' ? getGeckoLikelyMaxNonMutedPlaybackRate()
popupSoundedSpeedStep: 0.25,
popupSilenceSpeedRawMin: 1,
// See the comment in `getAbsoluteClampedSilenceSpeed` definition on why `max` is different
// for different browsers.
popupSilenceSpeedRawMax: BUILD_DEFINITIONS.BROWSER === 'gecko'
// But if the browser gets upgraded, this will remain at 4. Doesn't matter?
? Math.min(8, getGeckoLikelyMaxNonMutedPlaybackRate())
: 8,
popupSilenceSpeedRawStep: 0.25,
popupMarginBeforeMin: 0,
popupMarginBeforeMax: 0.5,
popupMarginBeforeStep: 0.010,
popupMarginAfterMin: 0,
popupMarginAfterMax: 0.5,
popupMarginAfterStep: 0.010,
popupSpecificHotkeys: [
{
keyCombination: { code: 'Space', },
action: HotkeyAction.TOGGLE_PAUSE,
},
{
keyCombination: { code: 'ArrowLeft' },
action: HotkeyAction.REWIND,
actionArgument: 5,
},
{
keyCombination: { code: 'ArrowRight' },
action: HotkeyAction.ADVANCE,
actionArgument: 5,
},
{
keyCombination: { code: 'ArrowUp' },
action: HotkeyAction.INCREASE_VOLUME,
actionArgument: 5,
},
{
keyCombination: { code: 'ArrowDown' },
action: HotkeyAction.DECREASE_VOLUME,
actionArgument: 5,
},
],
timeSavedAveragingMethod: 'exponential',
timeSavedAveragingWindowLength: 600,
timeSavedExponentialAveragingLatestDataWeight: 0.95,
badgeWhatSettingToDisplayByDefault: 'soundedSpeed',
enableDesyncCorrection: BUILD_DEFINITIONS.BROWSER === 'chromium'
// 2025-08-01. In case I get hit by a bus. I sure hope they'll fix it by that time.
// https://bugs.chromium.org/p/chromium/issues/detail?id=1231093
? Date.now() < 1754006400000
: false,
};