@oxymoron.13/tizentube-s95b 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +49 -42
  2. package/S95B-CHANGES.txt +10 -4
  3. package/UPSTREAM-README.md +42 -0
  4. package/dist/userScript.js +2 -2
  5. package/mods/config.js +117 -0
  6. package/mods/domrect-polyfill.js +104 -0
  7. package/mods/features/adblock.js +584 -0
  8. package/mods/features/autoFrameRate.js +42 -0
  9. package/mods/features/enableFeatures.js +19 -0
  10. package/mods/features/moreSubtitles.js +378 -0
  11. package/mods/features/pictureInPicture.js +198 -0
  12. package/mods/features/preferredVideoQuality.js +101 -0
  13. package/mods/features/s95bCodec.js +45 -0
  14. package/mods/features/s95bI18n.js +28 -0
  15. package/mods/features/s95bMenu.js +142 -0
  16. package/mods/features/sponsorblock.js +437 -0
  17. package/mods/features/standaloneUserscript.js +107 -0
  18. package/mods/features/updater.js +119 -0
  19. package/mods/features/userAgentSpoofing.js +73 -0
  20. package/mods/features/videoQueuing.js +64 -0
  21. package/mods/package-lock.json +2321 -0
  22. package/mods/package.json +33 -0
  23. package/mods/resolveCommand.js +376 -0
  24. package/mods/rollup.config.js +41 -0
  25. package/mods/spatial-navigation-polyfill.js +1756 -0
  26. package/mods/tiny-sha256.js +99 -0
  27. package/mods/translations/i18nResources.js +11 -0
  28. package/mods/translations/index.js +18 -0
  29. package/mods/translations/language-names.js +981 -0
  30. package/mods/translations/resources/ar.json +308 -0
  31. package/mods/translations/resources/az.json +308 -0
  32. package/mods/translations/resources/bs.json +308 -0
  33. package/mods/translations/resources/cs.json +308 -0
  34. package/mods/translations/resources/de.json +308 -0
  35. package/mods/translations/resources/dk.json +308 -0
  36. package/mods/translations/resources/el.json +308 -0
  37. package/mods/translations/resources/en.json +308 -0
  38. package/mods/translations/resources/es-419.json +308 -0
  39. package/mods/translations/resources/es.json +308 -0
  40. package/mods/translations/resources/fi-FI.json +308 -0
  41. package/mods/translations/resources/fr.json +311 -0
  42. package/mods/translations/resources/hr.json +308 -0
  43. package/mods/translations/resources/hu.json +308 -0
  44. package/mods/translations/resources/id.json +308 -0
  45. package/mods/translations/resources/it.json +308 -0
  46. package/mods/translations/resources/ja.json +308 -0
  47. package/mods/translations/resources/lt.json +308 -0
  48. package/mods/translations/resources/lv.json +308 -0
  49. package/mods/translations/resources/pl.json +308 -0
  50. package/mods/translations/resources/pt-BR.json +308 -0
  51. package/mods/translations/resources/pt-PT.json +308 -0
  52. package/mods/translations/resources/ro.json +310 -0
  53. package/mods/translations/resources/ru.json +308 -0
  54. package/mods/translations/resources/sr-Cyrl.json +308 -0
  55. package/mods/translations/resources/sr-Latn.json +308 -0
  56. package/mods/translations/resources/tlh.json +308 -0
  57. package/mods/translations/resources/tr.json +308 -0
  58. package/mods/translations/resources/uk.json +308 -0
  59. package/mods/translations/resources/vi.json +309 -0
  60. package/mods/translations/resources/zh-CN.json +308 -0
  61. package/mods/translations/resources/zh-TW.json +308 -0
  62. package/mods/translations/update-translations.js +55 -0
  63. package/mods/ui/chapters.js +137 -0
  64. package/mods/ui/clock.js +71 -0
  65. package/mods/ui/customCommandExecution.js +49 -0
  66. package/mods/ui/customGuideAction.js +119 -0
  67. package/mods/ui/customUI.js +192 -0
  68. package/mods/ui/customYTSettings.js +29 -0
  69. package/mods/ui/disableWhosWatching.js +48 -0
  70. package/mods/ui/settings.js +1024 -0
  71. package/mods/ui/sidebarModification.js +179 -0
  72. package/mods/ui/speedUI.js +119 -0
  73. package/mods/ui/theme.js +26 -0
  74. package/mods/ui/ui.css +157 -0
  75. package/mods/ui/ui.js +261 -0
  76. package/mods/ui/ytUI.js +510 -0
  77. package/mods/userScript.js +28 -0
  78. package/mods/utils/ASTParser.js +67 -0
  79. package/mods/utils/innerTubeCalls.js +138 -0
  80. package/package.json +11 -5
  81. package/service/package-lock.json +4193 -0
  82. package/service/package.json +29 -0
  83. package/service/rollup.config.js +47 -0
  84. package/service/service.js +118 -0
package/mods/ui/ui.js ADDED
@@ -0,0 +1,261 @@
1
+ /*global navigate*/
2
+ import '../spatial-navigation-polyfill.js';
3
+ import css from './ui.css';
4
+ import { configRead, configWrite } from '../config.js';
5
+ import updateStyle from './theme.js';
6
+ import { showToast } from './ytUI.js';
7
+ import modernUI from './settings.js';
8
+ import resolveCommand, { patchResolveCommand } from '../resolveCommand.js';
9
+ import { pipToFullscreen } from '../features/pictureInPicture.js';
10
+ import getCommandExecutor from './customCommandExecution.js';
11
+ import { t } from 'i18next';
12
+
13
+ // It just works, okay?
14
+ const interval = setInterval(() => {
15
+ const videoElement = document.querySelector('video');
16
+ if (videoElement) {
17
+ execute_once_dom_loaded();
18
+ patchResolveCommand();
19
+ clearInterval(interval);
20
+ }
21
+ }, 250);
22
+
23
+ let keyTimeout = null;
24
+
25
+ const keys = {
26
+ 49: 1,
27
+ 50: 2,
28
+ 51: 3,
29
+ 52: 4,
30
+ 53: 5,
31
+ 54: 6,
32
+ 55: 7,
33
+ 56: 8,
34
+ 57: 9,
35
+ 48: 0
36
+ };
37
+
38
+ function execute_once_dom_loaded() {
39
+
40
+ // Add CSS to head.
41
+
42
+ const existingStyle = document.querySelector('style[nonce]');
43
+ if (existingStyle) {
44
+ existingStyle.textContent += css;
45
+ } else {
46
+ const style = document.createElement('style');
47
+ style.textContent = css;
48
+ document.head.appendChild(style);
49
+ }
50
+
51
+ // Fix UI issues.
52
+ const ui = configRead('enableFixedUI');
53
+ if (ui) {
54
+ try {
55
+ window.tectonicConfig.featureSwitches.isLimitedMemory = false;
56
+ window.tectonicConfig.clientData.legacyApplicationQuality = 'full-animation';
57
+ window.tectonicConfig.featureSwitches.enableAnimations = true;
58
+ window.tectonicConfig.featureSwitches.enableOnScrollLinearAnimation = true;
59
+ window.tectonicConfig.featureSwitches.enableListAnimations = true;
60
+ window.tectonicConfig.featureSwitches.supportsLongPress = true;
61
+ } catch (e) { }
62
+ }
63
+
64
+ // We handle key events ourselves.
65
+ window.__spatialNavigation__.keyMode = 'NONE';
66
+
67
+ var ARROW_KEY_CODE = { 37: 'left', 38: 'up', 39: 'right', 40: 'down' };
68
+
69
+ var uiContainer = document.createElement('div');
70
+ uiContainer.classList.add('ytaf-ui-container');
71
+ uiContainer.style['display'] = 'none';
72
+ uiContainer.setAttribute('tabindex', 0);
73
+ uiContainer.addEventListener(
74
+ 'focus',
75
+ () => console.info('uiContainer focused!'),
76
+ true
77
+ );
78
+ uiContainer.addEventListener(
79
+ 'blur',
80
+ () => console.info('uiContainer blured!'),
81
+ true
82
+ );
83
+
84
+ uiContainer.addEventListener(
85
+ 'keydown',
86
+ (evt) => {
87
+ console.info('uiContainer key event:', evt.type, evt.keyCode, evt);
88
+ if (evt.keyCode !== 404 && evt.keyCode !== 172) {
89
+ if (evt.keyCode in ARROW_KEY_CODE) {
90
+ navigate(ARROW_KEY_CODE[evt.keyCode]);
91
+ } else if (evt.keyCode === 13 || evt.keyCode === 32) {
92
+ // "OK" button
93
+ console.log('OK button pressed');
94
+ const focusedElement = document.querySelector(':focus');
95
+ if (focusedElement.type === 'checkbox') {
96
+ focusedElement.checked = !focusedElement.checked;
97
+ focusedElement.dispatchEvent(new Event('change'));
98
+ }
99
+ evt.preventDefault();
100
+ evt.stopPropagation();
101
+ return;
102
+ } else if (evt.keyCode === 27 && document.querySelector(':focus').type !== 'text') {
103
+ // Back button
104
+ uiContainer.style.display = 'none';
105
+ uiContainer.blur();
106
+ } else if (document.querySelector(':focus').type === 'text' && evt.keyCode === 27) {
107
+ const focusedElement = document.querySelector(':focus');
108
+ focusedElement.value = focusedElement.value.slice(0, -1);
109
+ }
110
+
111
+
112
+ if (evt.key === 'Enter' || evt.Uc?.key === 'Enter') {
113
+ // If the focused element is a text input, emit a change event.
114
+ if (document.querySelector(':focus').type === 'text') {
115
+ document.querySelector(':focus').dispatchEvent(new Event('change'));
116
+ }
117
+ }
118
+ }
119
+ },
120
+ true
121
+ );
122
+
123
+ try {
124
+ uiContainer.innerHTML = `
125
+ <h1>TizenTube Theme Configuration</h1>
126
+ <label for="__barColor">Navigation Bar Color: <input type="text" id="__barColor"/></label>
127
+ <label for="__routeColor">Main Content Color: <input type="text" id="__routeColor"/></label>
128
+ <div><small>Sponsor segments skipping - https://sponsor.ajay.app</small></div>
129
+ `;
130
+ document.querySelector('body').appendChild(uiContainer);
131
+
132
+ uiContainer.querySelector('#__barColor').value = configRead('focusContainerColor');
133
+ uiContainer.querySelector('#__barColor').addEventListener('change', (evt) => {
134
+ configWrite('focusContainerColor', evt.target.value);
135
+ updateStyle();
136
+ });
137
+
138
+ uiContainer.querySelector('#__routeColor').value = configRead('routeColor');
139
+ uiContainer.querySelector('#__routeColor').addEventListener('change', (evt) => {
140
+ configWrite('routeColor', evt.target.value);
141
+ updateStyle();
142
+ });
143
+ } catch (e) { }
144
+
145
+ var eventHandler = (evt) => {
146
+ // We handle key events ourselves.
147
+ console.info(
148
+ 'Key event:',
149
+ evt.type,
150
+ evt.keyCode,
151
+ evt.keyCode,
152
+ evt.defaultPrevented
153
+ );
154
+
155
+ if (evt.keyCode in keys) {
156
+ const percentage = keys[evt.keyCode] * 10;
157
+ const video = document.querySelector('video');
158
+ video.currentTime = (percentage / 100) * video.duration;
159
+ }
160
+
161
+ const container = document.getElementById('container');
162
+
163
+ if (window.screenTurnedOffAt && Date.now() - window.screenTurnedOffAt > 1000) {
164
+ for (const child of document.body.children) {
165
+ if (child.tagName.toLowerCase() === 'script' || child.tagName.toLowerCase() === 'svg') continue;
166
+
167
+ child.style.setProperty('display', 'block', 'important');
168
+ }
169
+ window.screenTurnedOffAt = null;
170
+ }
171
+
172
+ if (configRead('enableScreenDimming')) {
173
+ if (keyTimeout) {
174
+ clearTimeout(keyTimeout);
175
+ }
176
+ container.style.setProperty('opacity', '1', 'important');
177
+ keyTimeout = setTimeout(() => {
178
+ const videoPlayer = document.querySelector('.html5-video-player');
179
+ const playerStateObject = videoPlayer.getPlayerStateObject();
180
+ if (playerStateObject.isPlaying) return;
181
+ container.style.setProperty('opacity', (1 - configRead('dimmingOpacity')).toString(), 'important');
182
+ }, configRead('dimmingTimeout') * 1000);
183
+ }
184
+ if (evt.keyCode == 403) {
185
+ console.info('Taking over!');
186
+ evt.preventDefault();
187
+ evt.stopPropagation();
188
+ if (evt.type === 'keydown') {
189
+ try {
190
+ if (uiContainer.style.display === 'none') {
191
+ console.info('Showing and focusing!');
192
+ uiContainer.style.display = 'block';
193
+ uiContainer.focus();
194
+ } else {
195
+ console.info('Hiding!');
196
+ uiContainer.style.display = 'none';
197
+ uiContainer.blur();
198
+ }
199
+ } catch (e) { }
200
+ }
201
+ return false;
202
+ } else if (evt.keyCode == 404) {
203
+ if (evt.type === 'keydown') {
204
+ modernUI();
205
+ }
206
+ } else if (evt.keyCode == 39) {
207
+ // Right key, for PiP
208
+ if (evt.type === 'keydown') {
209
+ if (document.querySelector('ytlr-search-text-box > .zylon-focus') && window.isPipPlaying) {
210
+ const ytlrPlayer = document.querySelector('ytlr-player');
211
+ ytlrPlayer.style.setProperty('background-color', 'rgb(0, 0, 0)');
212
+ pipToFullscreen();
213
+ }
214
+ }
215
+ };
216
+ return true;
217
+ }
218
+
219
+ // Red, Green, Yellow, Blue
220
+ // 403, 404, 405, 406
221
+ // ---, 172, 170, 191
222
+ document.addEventListener('keydown', eventHandler, true);
223
+ document.addEventListener('keypress', eventHandler, true);
224
+ document.addEventListener('keyup', eventHandler, true);
225
+ if (configRead('showWelcomeToast')) {
226
+ setTimeout(() => {
227
+ showToast(t('welcomeMsg.title'), t('welcomeMsg.subtitle'));
228
+ }, 2000);
229
+ }
230
+
231
+ if (configRead('reloadHomeOnStartup')) {
232
+ if (configRead('launchToOnStartup')) {
233
+ resolveCommand(JSON.parse(configRead('launchToOnStartup')));
234
+ } else {
235
+ resolveCommand({
236
+ signalAction: {
237
+ signal: 'SOFT_RELOAD_PAGE'
238
+ }
239
+ });
240
+ }
241
+ }
242
+
243
+ const commandExecutor = getCommandExecutor();
244
+ if (commandExecutor) {
245
+ commandExecutor.executeFunction(new commandExecutor.commandFunction('reloadGuideAction'));
246
+ }
247
+
248
+ // Fix UI issues, again. Love, Googol.
249
+
250
+ if (configRead('enableFixedUI')) {
251
+ try {
252
+ const observer = new MutationObserver((_, _2) => {
253
+ const body = document.body;
254
+ if (body.classList.contains('app-quality-root')) {
255
+ body.classList.remove('app-quality-root');
256
+ }
257
+ });
258
+ observer.observe(document.body, { attributes: true, childList: false, subtree: false });
259
+ } catch (e) { }
260
+ }
261
+ }