@oxymoron.13/tizentube-s95b 0.1.1 → 0.2.0

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 +9 -3
  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 +34 -0
  15. package/mods/features/s95bMenu.js +223 -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
@@ -0,0 +1,45 @@
1
+ /* S95B Performance Edition – GPL-3.0-only.
2
+ * Pure, conservative format selector. Does not touch Samsung/Tizen APIs.
3
+ */
4
+ export function selectCodecFormats(response, codec) {
5
+ if (!response || !response.streamingData || !Array.isArray(response.streamingData.adaptiveFormats)) {
6
+ return { changed: false, reason: 'no-formats' };
7
+ }
8
+ if (codec !== 'vp9' && codec !== 'av01' && codec !== 'avc1') {
9
+ return { changed: false, reason: 'automatic' };
10
+ }
11
+
12
+ const formats = response.streamingData.adaptiveFormats;
13
+ const video = formats.filter(item => item && typeof item.mimeType === 'string' && /^video\//i.test(item.mimeType));
14
+ const isMatch = item => {
15
+ const mime = item.mimeType.toLowerCase();
16
+ if (codec === 'vp9') return /(?:vp9|vp09)/.test(mime);
17
+ if (codec === 'av01') return /av01/.test(mime);
18
+ return /avc1/.test(mime);
19
+ };
20
+ const selected = video.filter(isMatch);
21
+ if (!selected.length) return { changed: false, reason: 'codec-unavailable' };
22
+ if (selected.length === video.length) return { changed: false, reason: 'already-selected' };
23
+
24
+ // Conservative quality parity: preserve original formats if filtering could
25
+ // remove the best available height/fps combination. Metadata absent => no filter.
26
+ const valid = item => Number.isFinite(item.height) && item.height > 0 &&
27
+ Number.isFinite(item.fps) && item.fps > 0;
28
+ if (!video.every(valid) || !selected.every(valid)) {
29
+ return { changed: false, reason: 'quality-unknown' };
30
+ }
31
+ const maxHeight = Math.max(...video.map(item => item.height));
32
+ const maxFpsAtHeight = Math.max(...video.filter(item => item.height === maxHeight).map(item => item.fps));
33
+ const bestMatch = selected.some(item => item.height >= maxHeight && item.fps >= maxFpsAtHeight);
34
+ if (!bestMatch) return { changed: false, reason: 'quality-fallback' };
35
+
36
+ // Keep audio and unrecognized entries untouched. No media decoding or resampling.
37
+ const next = formats.filter(item => !item || typeof item.mimeType !== 'string' ||
38
+ !/^video\//i.test(item.mimeType) || isMatch(item));
39
+ if (!next.some(item => item && /^audio\//i.test(item.mimeType || ''))) {
40
+ // Do not make a pre-existing audio problem worse by filtering streams.
41
+ return { changed: false, reason: 'missing-audio' };
42
+ }
43
+ response.streamingData.adaptiveFormats = next;
44
+ return { changed: true, reason: 'selected' };
45
+ }
@@ -0,0 +1,34 @@
1
+ /* S95B Performance Edition – GPL-3.0-only */
2
+ export const STRINGS = Object.freeze({
3
+ de: Object.freeze({
4
+ title: 'S95B · Performance', subtitle: 'TizenTube Performance Edition 0.2.0',
5
+ language: 'Sprache', codec: 'Videocodec', automatic: 'Automatisch',
6
+ light: 'Ressourcenschonender Modus', diag: 'Diagnoseanzeige',
7
+ reset: 'Änderungen zurücksetzen', close: 'Schließen', on: 'Ein', off: 'Aus',
8
+ hint: 'Gelbe Taste: Einstellungen · Pfeile: Navigieren · OK: Ändern · Zurück: Schließen',
9
+ restart: 'Codec-Änderungen gelten ab dem nächsten Video. Eventuell ist ein Neustart nötig.',
10
+ safe: 'Kein Eingriff in Firmware, Bildrate oder Decoder.',
11
+ statVideo: 'Video', statFrames: 'Verlorene Bilder', statCodec: 'Codec-Wunsch',
12
+ statUnavailable: 'Vom Web-Player nicht verfügbar', statWait: 'Warte auf Video',
13
+ lightHint: 'Schaltet Vorschauen und DeArrow ab; vorherige Werte werden gesichert.',
14
+ restoreHint: 'Stellt nur die von diesem Menü geänderten Werte wieder her.',
15
+ languageDE: 'Deutsch', languageEN: 'English',
16
+ }),
17
+ en: Object.freeze({
18
+ title: 'S95B · Performance', subtitle: 'TizenTube Performance Edition 0.2.0',
19
+ language: 'Language', codec: 'Video codec', automatic: 'Automatic',
20
+ light: 'Low-overhead mode', diag: 'Diagnostic overlay',
21
+ reset: 'Restore changed settings', close: 'Close', on: 'On', off: 'Off',
22
+ hint: 'Yellow button: settings · Arrows: navigate · OK: change · Back: close',
23
+ restart: 'Codec changes take effect with the next video. A restart may be needed.',
24
+ safe: 'No firmware, display-rate or decoder changes.',
25
+ statVideo: 'Video', statFrames: 'Dropped frames', statCodec: 'Codec preference',
26
+ statUnavailable: 'Not available from web player', statWait: 'Waiting for video',
27
+ lightHint: 'Disables previews and DeArrow; original values are backed up.',
28
+ restoreHint: 'Restores only values changed from this menu.',
29
+ languageDE: 'Deutsch', languageEN: 'English',
30
+ })
31
+ });
32
+ export function translate(lang, key) {
33
+ return (STRINGS[lang] || STRINGS.de)[key] || STRINGS.en[key] || key;
34
+ }
@@ -0,0 +1,223 @@
1
+ /* S95B Performance Edition – GPL-3.0-only
2
+ * No global player hooks, firmware calls, network requests, or external scripts.
3
+ * UI runs only when the TizenTube userscript loads, keyboard events only when
4
+ * explicitly invoked. Uses existing TizenTube configRead/configWrite APIs.
5
+ */
6
+ import { configRead, configWrite } from '../config.js';
7
+ import { translate } from './s95bI18n.js';
8
+
9
+ const STATE_KEY = 's95b-perf-edition-v1';
10
+ const EDITED = ['enablePreviews', 'enableDeArrow', 'enableDeArrowThumbnails'];
11
+ const defaultState = { lang: 'de', light: false, diagnostics: false, previous: null, codecPrevious: null };
12
+ let state = { ...defaultState };
13
+ let overlay = null;
14
+ let diagnostic = null;
15
+ let diagTimer = null;
16
+ let menuButtons = [];
17
+ let selected = 0;
18
+
19
+ function readState() {
20
+ try {
21
+ const data = JSON.parse(localStorage.getItem(STATE_KEY) || 'null');
22
+ if (data && typeof data === 'object') {
23
+ state = { ...defaultState,
24
+ lang: data.lang === 'en' ? 'en' : 'de', light: data.light === true,
25
+ diagnostics: data.diagnostics === true,
26
+ previous: data.previous && typeof data.previous === 'object' ? data.previous : null,
27
+ codecPrevious: typeof data.codecPrevious === 'string' ? data.codecPrevious : null };
28
+ }
29
+ } catch (_) { state = { ...defaultState }; }
30
+ }
31
+ function save() {
32
+ try { localStorage.setItem(STATE_KEY, JSON.stringify(state)); } catch (_) { /* no persistent storage */ }
33
+ }
34
+ function currentCodec() {
35
+ const value = configRead('preferredVideoCodec');
36
+ return value === 'vp9' || value === 'av01' || value === 'avc1' ? value : 'any';
37
+ }
38
+ function codecLabel(value) {
39
+ return value === 'any' ? translate(state.lang, 'automatic') : value === 'vp9' ? 'VP9' : value === 'av01' ? 'AV1' : 'H.264';
40
+ }
41
+ function changeCodec() {
42
+ if (state.codecPrevious === null) state.codecPrevious = String(configRead('preferredVideoCodec') || 'any');
43
+ configWrite('preferredVideoCodec', currentCodec() === 'vp9' ? 'any' : 'vp9');
44
+ save();
45
+ }
46
+ function turnLight(enable) {
47
+ if (enable === state.light) return;
48
+ if (enable) {
49
+ const values = {};
50
+ EDITED.forEach(key => { values[key] = configRead(key); });
51
+ state.previous = values;
52
+ EDITED.forEach(key => configWrite(key, false));
53
+ state.light = true;
54
+ } else {
55
+ if (state.previous) EDITED.forEach(key => {
56
+ if (Object.prototype.hasOwnProperty.call(state.previous, key)) {
57
+ configWrite(key, state.previous[key]);
58
+ }
59
+ });
60
+ state.previous = null;
61
+ state.light = false;
62
+ }
63
+ save();
64
+ }
65
+ function reset() {
66
+ turnLight(false);
67
+ if (state.codecPrevious !== null) {
68
+ configWrite('preferredVideoCodec', state.codecPrevious);
69
+ state.codecPrevious = null;
70
+ }
71
+ state.diagnostics = false;
72
+ stopDiagnostics();
73
+ save();
74
+ }
75
+ function create(tag, attrs, value) {
76
+ const n = document.createElement(tag);
77
+ if (attrs) Object.keys(attrs).forEach(key => {
78
+ if (key === 'className') n.className = attrs[key];
79
+ else n.setAttribute(key, attrs[key]);
80
+ });
81
+ if (typeof value === 'string') n.textContent = value;
82
+ return n;
83
+ }
84
+ function drawMenu() {
85
+ if (!overlay) return;
86
+ overlay.textContent = '';
87
+ const t = key => translate(state.lang, key);
88
+ const card = create('section', { className: 's95b-card', role: 'dialog', 'aria-modal': 'true', 'aria-label': t('title') });
89
+ const eyebrow = create('div', { className: 's95b-eyebrow' }, t('subtitle'));
90
+ const title = create('h2', null, t('title'));
91
+ card.append(eyebrow, title);
92
+ const fields = [
93
+ [t('language'), state.lang === 'de' ? t('languageDE') : t('languageEN'), () => { state.lang = state.lang === 'de' ? 'en' : 'de'; save(); }],
94
+ [t('codec'), codecLabel(currentCodec()), changeCodec],
95
+ [t('light'), state.light ? t('on') : t('off'), () => turnLight(!state.light)],
96
+ [t('diag'), state.diagnostics ? t('on') : t('off'), () => { state.diagnostics = !state.diagnostics; save(); if (state.diagnostics) startDiagnostics(); else stopDiagnostics(); }],
97
+ [t('reset'), '', reset],
98
+ [t('close'), '', hideMenu]
99
+ ];
100
+ menuButtons = fields.map((field, index) => {
101
+ const button = create('button', { type: 'button', className: 's95b-option', 'data-index': String(index) });
102
+ button.append(create('span', null, field[0]), create('strong', null, field[1]));
103
+ button.addEventListener('click', () => { selected = index; field[2](); if (overlay) drawMenu(); });
104
+ card.appendChild(button);
105
+ return button;
106
+ });
107
+ card.append(create('p', { className: 's95b-explanation' }, t('lightHint')));
108
+ card.append(create('p', { className: 's95b-note' }, t('restart')));
109
+ card.append(create('p', { className: 's95b-note' }, t('restoreHint')));
110
+ card.append(create('p', { className: 's95b-footer' }, t('safe')));
111
+ card.append(create('p', { className: 's95b-footer' }, t('hint')));
112
+ overlay.appendChild(card);
113
+ selected = Math.max(0, Math.min(selected, menuButtons.length - 1));
114
+ highlight();
115
+ }
116
+ function highlight() {
117
+ menuButtons.forEach((b, i) => {
118
+ b.classList.toggle('s95b-active', i === selected);
119
+ b.setAttribute('tabindex', i === selected ? '0' : '-1');
120
+ });
121
+ if (menuButtons[selected]) menuButtons[selected].focus();
122
+ }
123
+ function openMenu() {
124
+ if (!document.body) return;
125
+ if (overlay) { hideMenu(); return; }
126
+ overlay = create('div', { id: 's95b-overlay' });
127
+ document.body.appendChild(overlay);
128
+ selected = 0;
129
+ drawMenu();
130
+ }
131
+ function hideMenu() {
132
+ if (overlay) overlay.remove();
133
+ overlay = null;
134
+ menuButtons = [];
135
+ }
136
+ function fmtVideo(v) {
137
+ const t = key => translate(state.lang, key);
138
+ if (!v) return t('statWait');
139
+ const width = v.videoWidth || 0;
140
+ const height = v.videoHeight || 0;
141
+ return width > 0 && height > 0 ? `${width} × ${height}` : t('statUnavailable');
142
+ }
143
+ function updateDiagnostics() {
144
+ if (!diagnostic) return;
145
+ const t = key => translate(state.lang, key);
146
+ const video = document.querySelector('video');
147
+ const codec = codecLabel(currentCodec());
148
+ let dropped = t('statUnavailable');
149
+ if (video && typeof video.getVideoPlaybackQuality === 'function') {
150
+ try {
151
+ const q = video.getVideoPlaybackQuality();
152
+ if (q && Number.isFinite(q.droppedVideoFrames)) dropped = String(q.droppedVideoFrames);
153
+ } catch (_) { /* diagnostics should never interrupt playback */ }
154
+ }
155
+ diagnostic.textContent = [t('statVideo') + ': ' + fmtVideo(video), t('statFrames') + ': ' + dropped,
156
+ t('statCodec') + ': ' + codec].join(' | ');
157
+ }
158
+ function startDiagnostics() {
159
+ if (!document.body || diagnostic) return;
160
+ diagnostic = create('div', { id: 's95b-diagnostics', role: 'status' });
161
+ document.body.appendChild(diagnostic);
162
+ updateDiagnostics();
163
+ // Interval is deliberately disabled unless explicitly enabled by the user.
164
+ diagTimer = setInterval(updateDiagnostics, 2000);
165
+ }
166
+ function stopDiagnostics() {
167
+ if (diagTimer !== null) clearInterval(diagTimer);
168
+ diagTimer = null;
169
+ if (diagnostic) diagnostic.remove();
170
+ diagnostic = null;
171
+ }
172
+ function onKeys(e) {
173
+ const code = e.keyCode || e.which;
174
+ const isKeydown = e.type === undefined || e.type === 'keydown';
175
+ // Samsung ColorF2Yellow (405) or an optional external keyboard's F2.
176
+ // Red (403), green (404) and blue (406) are already used by TizenTube itself.
177
+ if (code === 405 || e.key === 'F2') {
178
+ e.preventDefault(); e.stopImmediatePropagation();
179
+ if (isKeydown) openMenu();
180
+ return;
181
+ }
182
+ if (!overlay) return; // Do not interfere with normal YouTube key navigation.
183
+ const back = code === 10009 || code === 8 || code === 27 || e.key === 'Escape' || e.key === 'Backspace';
184
+ const up = code === 38 || e.key === 'ArrowUp';
185
+ const down = code === 40 || e.key === 'ArrowDown';
186
+ const enter = code === 13 || e.key === 'Enter';
187
+ if (!(back || up || down || enter)) return;
188
+ // keyup/keypress of handled keys are swallowed too, so the YouTube UI below never sees half a key press.
189
+ e.preventDefault(); e.stopImmediatePropagation();
190
+ if (!isKeydown) return;
191
+ if (back) hideMenu();
192
+ else if (up || down) { selected = (selected + (up ? -1 : 1) + menuButtons.length) % menuButtons.length; highlight(); }
193
+ else if (menuButtons[selected]) menuButtons[selected].click();
194
+ }
195
+ function init() {
196
+ if (!document.body || document.getElementById('s95b-style')) return;
197
+ const css = `
198
+ #s95b-overlay {position:fixed;top:0;left:0;right:0;bottom:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.78);font-family:Arial,Helvetica,sans-serif;color:#f7fafc;}
199
+ #s95b-overlay * {box-sizing:border-box;}
200
+ #s95b-overlay .s95b-card {width:88vw;max-width:930px;max-height:90vh;overflow:auto;background:#111a27;border:2px solid #34506c;border-radius:18px;padding:28px 34px;box-shadow:0 20px 70px rgba(0,0,0,.55);}
201
+ #s95b-overlay .s95b-eyebrow {font-size:19px;color:#a8cce0;}
202
+ #s95b-overlay h2 {font-size:38px;line-height:1.2;margin:6px 0 18px;}
203
+ #s95b-overlay button {width:100%;display:flex;align-items:center;justify-content:space-between;font-size:24px;line-height:1.2;color:#fff;text-align:left;padding:14px 18px;margin:6px 0;border:2px solid #26374b;border-radius:10px;background:#192638;cursor:pointer;}
204
+ #s95b-overlay button strong {color:#bcecff;font-size:22px;margin-left:24px;}
205
+ #s95b-overlay button.s95b-active,#s95b-overlay button:focus {background:#176687;border-color:#bcecff;outline:none;}
206
+ #s95b-overlay p {font-size:17px;line-height:1.45;}
207
+ #s95b-overlay .s95b-explanation {color:#bcd9df;margin:17px 0 4px;}
208
+ #s95b-overlay .s95b-note {color:#d7dce5;margin:7px 0;}
209
+ #s95b-overlay .s95b-footer {color:#91a0b3;margin:10px 0 0;font-size:15px;}
210
+ #s95b-diagnostics {pointer-events:none;position:fixed;bottom:2vh;left:2vw;z-index:2147483645;padding:10px 16px;color:white;background:rgba(0,0,0,.7);font:15px Arial,Helvetica,sans-serif;border-radius:8px;}
211
+ `;
212
+ const style = create('style', { id: 's95b-style' });
213
+ style.textContent = css;
214
+ document.head.appendChild(style);
215
+ // Register our listener in the capture phase; only known menu keys are consumed.
216
+ window.addEventListener('keydown', onKeys, true);
217
+ window.addEventListener('keyup', onKeys, true);
218
+ window.addEventListener('keypress', onKeys, true);
219
+ if (state.diagnostics) startDiagnostics();
220
+ }
221
+ readState();
222
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init, { once: true });
223
+ else init();