@krx3d/tizentube2 1.30.70 → 1.30.80
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.
- package/dist/userScript.js +1 -1
- package/package.json +1 -1
- package/standalone/index.html +88 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krx3d/tizentube2",
|
|
3
3
|
"appName": "TizenTube",
|
|
4
|
-
"version": "1.30.
|
|
4
|
+
"version": "1.30.80",
|
|
5
5
|
"description": "TizenTube is an ad-free and sponsor-free solution for your favourite streaming website on your Tizen (Samsung) TVs.",
|
|
6
6
|
"packageType": "mods",
|
|
7
7
|
"websiteURL": "https://youtube.com/tv?additionalDataUrl=http%3A%2F%2Flocalhost%3A8085%2Fdial%2Fapps%2FYouTube",
|
package/standalone/index.html
CHANGED
|
@@ -200,6 +200,93 @@
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
// Reported on Tizen 6.5: powering the TV on sometimes lands on the
|
|
204
|
+
// webview's own error page (ERR_INTERNET_DISCONNECTED) instead of
|
|
205
|
+
// YouTube. Chromium raises that when it believes the device is offline,
|
|
206
|
+
// so a navigation went out before the network had come back from
|
|
207
|
+
// standby. Both paths below navigate to YouTube almost at once, so hold
|
|
208
|
+
// them until the network is really there.
|
|
209
|
+
//
|
|
210
|
+
// Deliberately a no-op on a normal launch: if the browser already
|
|
211
|
+
// reports a link at the first check, this proceeds immediately without
|
|
212
|
+
// probing anything. The probe only runs when the app starts offline,
|
|
213
|
+
// which is the case being fixed — so even a probe that misbehaved on
|
|
214
|
+
// some firmware could never slow down an ordinary start.
|
|
215
|
+
var NETWORK_WAIT_MAX_MS = 60000;
|
|
216
|
+
var NETWORK_PROBE_TIMEOUT_MS = 4000;
|
|
217
|
+
|
|
218
|
+
function waitForNetworkThen(next) {
|
|
219
|
+
var started = Date.now();
|
|
220
|
+
var attempts = 0;
|
|
221
|
+
var delay = 1000;
|
|
222
|
+
|
|
223
|
+
if (navigator.onLine !== false) {
|
|
224
|
+
next();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
sendLog('INFO', 'Started offline, waiting for the network before loading YouTube');
|
|
228
|
+
|
|
229
|
+
function retry(reason) {
|
|
230
|
+
if (Date.now() - started >= NETWORK_WAIT_MAX_MS) {
|
|
231
|
+
// Past this point waiting further is not helping; proceed and
|
|
232
|
+
// let the existing paths do what they did before this check.
|
|
233
|
+
sendLog('ERROR', 'Network still not ready after ' + (Date.now() - started) + 'ms (' + reason + '), continuing anyway');
|
|
234
|
+
next();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (attempts === 1 || attempts % 5 === 0) {
|
|
238
|
+
sendLog('INFO', 'Waiting for network (' + reason + ', attempt ' + attempts + ')');
|
|
239
|
+
}
|
|
240
|
+
// Whichever comes first — the delay or the link coming back —
|
|
241
|
+
// runs the next attempt, and cancels the other. Leaving the
|
|
242
|
+
// listener behind would start a second attempt chain in
|
|
243
|
+
// parallel, and that one could call next() a second time.
|
|
244
|
+
var fired = false;
|
|
245
|
+
function go() {
|
|
246
|
+
if (fired) return;
|
|
247
|
+
fired = true;
|
|
248
|
+
clearTimeout(timer);
|
|
249
|
+
window.removeEventListener('online', go);
|
|
250
|
+
attempt();
|
|
251
|
+
}
|
|
252
|
+
var timer = setTimeout(go, delay);
|
|
253
|
+
window.addEventListener('online', go);
|
|
254
|
+
delay = Math.min(Math.round(delay * 1.5), 5000);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function attempt() {
|
|
258
|
+
attempts++;
|
|
259
|
+
if (navigator.onLine === false) {
|
|
260
|
+
retry('navigator.onLine is false');
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
var finished = false;
|
|
264
|
+
var timer = setTimeout(function () {
|
|
265
|
+
if (finished) return;
|
|
266
|
+
finished = true;
|
|
267
|
+
retry('probe timed out');
|
|
268
|
+
}, NETWORK_PROBE_TIMEOUT_MS);
|
|
269
|
+
// generate_204 answers with an empty 204; no-cors because only
|
|
270
|
+
// whether it arrives matters, not what it says.
|
|
271
|
+
fetch('https://www.youtube.com/generate_204?_=' + Date.now(), { mode: 'no-cors', cache: 'no-store', credentials: 'omit' })
|
|
272
|
+
.then(function () {
|
|
273
|
+
if (finished) return;
|
|
274
|
+
finished = true;
|
|
275
|
+
clearTimeout(timer);
|
|
276
|
+
sendLog('INFO', 'Network ready after ' + (Date.now() - started) + 'ms, ' + attempts + ' check(s)');
|
|
277
|
+
next();
|
|
278
|
+
})
|
|
279
|
+
.catch(function (e) {
|
|
280
|
+
if (finished) return;
|
|
281
|
+
finished = true;
|
|
282
|
+
clearTimeout(timer);
|
|
283
|
+
retry('probe failed: ' + (e && e.message || e));
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
attempt();
|
|
288
|
+
}
|
|
289
|
+
|
|
203
290
|
function launchService() {
|
|
204
291
|
sendLog('INFO', 'Launching StandaloneService via launchAppControl');
|
|
205
292
|
tizen.application.launchAppControl(
|
|
@@ -207,7 +294,7 @@
|
|
|
207
294
|
serviceId,
|
|
208
295
|
function () {
|
|
209
296
|
sendLog('INFO', 'launchAppControl success callback fired');
|
|
210
|
-
useInjectorOrProxy
|
|
297
|
+
waitForNetworkThen(useInjectorOrProxy);
|
|
211
298
|
},
|
|
212
299
|
function (e) {
|
|
213
300
|
// Confirmed on-device: right after a TV reboot, this can
|