@krx3d/tizentube2 1.15.970 → 1.15.990
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 +58 -30
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krx3d/tizentube2",
|
|
3
3
|
"appName": "TizenTube",
|
|
4
|
-
"version": "1.15.
|
|
4
|
+
"version": "1.15.990",
|
|
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
|
@@ -47,12 +47,37 @@
|
|
|
47
47
|
// firing at all). Same /tv-log target and payload shape as the
|
|
48
48
|
// service's own relayLog, so scripts/log-receiver/receiver.ps1 needs
|
|
49
49
|
// no changes.
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
// No address is written down here any more. index.html cannot read the
|
|
51
|
+
// page's settings — those live in localStorage on a different origin —
|
|
52
|
+
// so instead of carrying a constant it hands its lines to the service,
|
|
53
|
+
// which knows the receiver the user configured in the settings menu and
|
|
54
|
+
// persists it across restarts.
|
|
55
|
+
//
|
|
56
|
+
// The service is not listening yet when the first lines are produced, so
|
|
57
|
+
// they are buffered and flushed as soon as it answers. Bounded, because
|
|
58
|
+
// a service that never comes up must not grow this forever.
|
|
59
|
+
var MAX_BUFFERED_LOGS = 100;
|
|
60
|
+
var bufferedLogs = [];
|
|
61
|
+
|
|
62
|
+
function postLog(entry) {
|
|
63
|
+
return fetch('http://localhost:8099/tizentube/log', {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers: { 'Content-Type': 'application/json' },
|
|
66
|
+
body: JSON.stringify({ entry: entry })
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function flushBufferedLogs() {
|
|
71
|
+
if (!bufferedLogs.length) return;
|
|
72
|
+
var pending = bufferedLogs.splice(0, bufferedLogs.length);
|
|
73
|
+
for (var i = 0; i < pending.length; i++) {
|
|
74
|
+
(function (entry) {
|
|
75
|
+
try {
|
|
76
|
+
postLog(entry).catch(function () { });
|
|
77
|
+
} catch (e) { }
|
|
78
|
+
})(pending[i]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
56
81
|
|
|
57
82
|
function sendLog(level, message) {
|
|
58
83
|
var ts = new Date().toISOString();
|
|
@@ -64,30 +89,14 @@
|
|
|
64
89
|
context: 'StandaloneIndexHtml',
|
|
65
90
|
message: message
|
|
66
91
|
};
|
|
67
|
-
// Posted straight to the receiver, because this runs before the
|
|
68
|
-
// service exists and has to catch failures that stop it starting.
|
|
69
92
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})
|
|
75
|
-
} catch (e) {
|
|
76
|
-
|
|
77
|
-
// logServiceEvent, plus everything the injector relays — pass no
|
|
78
|
-
// host, so blanking its hardcoded default silenced that entire
|
|
79
|
-
// channel. Telling it the address here brings [StandaloneService]
|
|
80
|
-
// and [Injector] lines back. Only the address is sent, not the
|
|
81
|
-
// entry, so nothing is logged twice; retried until one gets
|
|
82
|
-
// through, because the service may not be listening yet.
|
|
83
|
-
if (!receiverAnnounced) {
|
|
84
|
-
try {
|
|
85
|
-
fetch('http://localhost:8099/tizentube/receiver', {
|
|
86
|
-
method: 'POST',
|
|
87
|
-
headers: { 'Content-Type': 'application/json' },
|
|
88
|
-
body: JSON.stringify({ host: LOG_RECEIVER_HOST, port: LOG_RECEIVER_PORT })
|
|
89
|
-
}).then(function () { receiverAnnounced = true; }).catch(function () { });
|
|
90
|
-
} catch (e) { }
|
|
93
|
+
postLog(entry).then(function () {
|
|
94
|
+
flushBufferedLogs();
|
|
95
|
+
}).catch(function () {
|
|
96
|
+
if (bufferedLogs.length < MAX_BUFFERED_LOGS) bufferedLogs.push(entry);
|
|
97
|
+
});
|
|
98
|
+
} catch (e) {
|
|
99
|
+
if (bufferedLogs.length < MAX_BUFFERED_LOGS) bufferedLogs.push(entry);
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
|
|
@@ -126,6 +135,12 @@
|
|
|
126
135
|
var MAX_CONNECTING_POLLS = 30;
|
|
127
136
|
var connectingPolls = 0;
|
|
128
137
|
|
|
138
|
+
// The service needs roughly three seconds to listen; these cover that
|
|
139
|
+
// without restarting the page underneath it.
|
|
140
|
+
var MAX_STARTUP_RETRIES = 20;
|
|
141
|
+
var STARTUP_RETRY_MS = 300;
|
|
142
|
+
var startupRetries = 0;
|
|
143
|
+
|
|
129
144
|
function useInjectorOrProxy() {
|
|
130
145
|
sendLog('INFO', 'useInjectorOrProxy() called, fetching getState');
|
|
131
146
|
const data = tizen.application.getCurrentApplication().getRequestedAppControl().appControl.data;
|
|
@@ -167,7 +182,20 @@
|
|
|
167
182
|
location.href = `http://localhost:8099/tv?additionalDataUrl=http%3A%2F%2Flocalhost%3A8095%2Fdial%2Fapps%2FYouTube${args ? `&${args}` : ''}`
|
|
168
183
|
}
|
|
169
184
|
}).catch((err) => {
|
|
170
|
-
|
|
185
|
+
// The service takes a couple of seconds to come up, and every
|
|
186
|
+
// getState during that window fails. Reloading the whole page
|
|
187
|
+
// for each one restarted launchAppControl too, producing 16
|
|
188
|
+
// reloads in 3 seconds on a 6.5 capture — wasted work that
|
|
189
|
+
// shows up as a long wait on the loading screen. Retry just
|
|
190
|
+
// the fetch instead, and only fall back to a reload once it
|
|
191
|
+
// is clear the service is not merely slow to start.
|
|
192
|
+
startupRetries++;
|
|
193
|
+
if (startupRetries <= MAX_STARTUP_RETRIES) {
|
|
194
|
+
sendLog('INFO', 'getState not up yet, retrying in ' + STARTUP_RETRY_MS + 'ms (' + startupRetries + '/' + MAX_STARTUP_RETRIES + ')');
|
|
195
|
+
setTimeout(useInjectorOrProxy, STARTUP_RETRY_MS);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
sendLog('ERROR', 'getState still failing after ' + MAX_STARTUP_RETRIES + ' retries, reloading: ' + (err && err.message || err));
|
|
171
199
|
window.location.reload();
|
|
172
200
|
});
|
|
173
201
|
}
|