@etspress/netflix 0.0.0-stage → 0.1.1
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/.env.example +2 -0
- package/README.md +14 -2
- package/package.json +44 -4
- package/plugin.json +46 -0
- package/public/assets/reference-logo.png +0 -0
- package/public/assets/reference-logo.svg +1 -0
- package/public/assets/service-24hours.png +0 -0
- package/public/assets/service-fast.png +0 -0
- package/public/assets/service-replace.png +0 -0
- package/public/assets/stat-members.svg +1 -0
- package/public/assets/stat-riders.svg +1 -0
- package/public/assets/stat-shield.svg +1 -0
- package/public/assets/stat-support.svg +1 -0
- package/public/config.html +72 -0
- package/public/config.js +282 -0
- package/public/console.css +153 -0
- package/public/console.js +484 -0
- package/public/home.css +391 -0
- package/public/home.js +445 -0
- package/public/icon.svg +1 -0
- package/public/inject.js +370 -0
package/public/inject.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
var pluginId = 'netflix';
|
|
3
|
+
var adminPath = '/admin/';
|
|
4
|
+
if (window.location.pathname.indexOf(adminPath) !== 0) return;
|
|
5
|
+
if (window.__NETFLIX_THEME_SETTINGS_INJECTOR__) return;
|
|
6
|
+
window.__NETFLIX_THEME_SETTINGS_INJECTOR__ = true;
|
|
7
|
+
|
|
8
|
+
var apiBase = '/plugins/appstore/api';
|
|
9
|
+
var configKey = 'NETFLIX_HOME_CONFIG';
|
|
10
|
+
var state = {
|
|
11
|
+
enabled: false,
|
|
12
|
+
configLoaded: false,
|
|
13
|
+
home: {},
|
|
14
|
+
storefrontTemplate: '',
|
|
15
|
+
productLayout: '',
|
|
16
|
+
checking: false,
|
|
17
|
+
loadingConfig: false,
|
|
18
|
+
observer: null,
|
|
19
|
+
style: null
|
|
20
|
+
};
|
|
21
|
+
var choices = {
|
|
22
|
+
storefrontTemplate: {
|
|
23
|
+
groupTitle: '店面模板',
|
|
24
|
+
title: '流媒体合租',
|
|
25
|
+
description: '流媒体合租主题首页与商店展示样式',
|
|
26
|
+
gridClass: 'netflix-theme-store-grid',
|
|
27
|
+
value: 'netflix',
|
|
28
|
+
icon: '<path d="M4 5.5h16a1.5 1.5 0 0 1 1.5 1.5v10a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 17V7A1.5 1.5 0 0 1 4 5.5Z"/><path d="m10 8.5 5 3.5-5 3.5z"/>'
|
|
29
|
+
},
|
|
30
|
+
productLayout: {
|
|
31
|
+
groupTitle: '商品布局',
|
|
32
|
+
title: '流媒体合租专用',
|
|
33
|
+
description: '适配流媒体合租主题的商品卡片布局',
|
|
34
|
+
gridClass: 'netflix-theme-layout-grid',
|
|
35
|
+
value: 'netflix-special',
|
|
36
|
+
icon: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M8 4v16M3 10h5m0 4h16"/>'
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var unselectedCardClass = 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 relative flex cursor-pointer flex-col items-center gap-3 rounded-xl border-2 p-6 transition-all border-border hover:border-muted-foreground/30';
|
|
40
|
+
var selectedCardClass = 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 relative flex cursor-pointer flex-col items-center gap-3 rounded-xl border-2 p-6 transition-all border-primary bg-primary/5 ring-1 ring-primary/20';
|
|
41
|
+
var unselectedIconClass = 'flex h-16 w-16 items-center justify-center rounded-xl bg-muted text-muted-foreground';
|
|
42
|
+
var selectedIconClass = 'flex h-16 w-16 items-center justify-center rounded-xl bg-primary/10 text-primary';
|
|
43
|
+
var unselectedTitleClass = 'font-semibold';
|
|
44
|
+
var selectedTitleClass = 'font-semibold text-primary';
|
|
45
|
+
|
|
46
|
+
function isSettingsRoute() {
|
|
47
|
+
return /\/admin\/settings\/?$/.test(window.location.pathname);
|
|
48
|
+
}
|
|
49
|
+
function isAdminRoute() {
|
|
50
|
+
return /\/admin(?:\/|$)/.test(window.location.pathname);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function authHeaders(hasBody) {
|
|
54
|
+
var headers = { 'X-AppStore-Actor': 'dujiao-admin' };
|
|
55
|
+
try {
|
|
56
|
+
var token = window.localStorage.getItem('admin_token') || '';
|
|
57
|
+
if (token) headers.Authorization = 'Bearer ' + token;
|
|
58
|
+
} catch (_error) {}
|
|
59
|
+
if (hasBody) headers['Content-Type'] = 'application/json';
|
|
60
|
+
return headers;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function request(path, options) {
|
|
64
|
+
var settings = options || {};
|
|
65
|
+
return fetch(apiBase + path, Object.assign({
|
|
66
|
+
credentials: 'same-origin',
|
|
67
|
+
headers: authHeaders(settings.body !== undefined)
|
|
68
|
+
}, settings)).then(async function (response) {
|
|
69
|
+
var payload = await response.json().catch(function () { return {}; });
|
|
70
|
+
if (!response.ok || payload.ok === false) throw new Error(payload.message || ('请求失败(HTTP ' + response.status + ')'));
|
|
71
|
+
return payload;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function ensureStyle() {
|
|
76
|
+
if (state.style && document.contains(state.style)) return;
|
|
77
|
+
var style = document.createElement('style');
|
|
78
|
+
style.id = 'netflix-theme-admin-options-style';
|
|
79
|
+
style.textContent = [
|
|
80
|
+
'.netflix-theme-store-grid{grid-template-columns:repeat(4,minmax(0,1fr))!important}',
|
|
81
|
+
'.netflix-theme-layout-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important}',
|
|
82
|
+
'@media(max-width:1023px){.netflix-theme-store-grid,.netflix-theme-layout-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}}',
|
|
83
|
+
'@media(max-width:639px){.netflix-theme-store-grid,.netflix-theme-layout-grid{grid-template-columns:minmax(0,1fr)!important}}',
|
|
84
|
+
'.netflix-theme-plugin-selected>label{border-color:hsl(var(--border))!important;background:transparent!important;box-shadow:none!important}',
|
|
85
|
+
'.netflix-theme-plugin-selected>label>.absolute{display:none!important}',
|
|
86
|
+
'.netflix-theme-plugin-selected>label>div.flex.h-16.w-16{background:hsl(var(--muted))!important;color:hsl(var(--muted-foreground))!important}',
|
|
87
|
+
'.netflix-theme-plugin-selected>label>.text-center>div:first-child{color:hsl(var(--muted-foreground))!important}',
|
|
88
|
+
'.netflix-theme-option{position:relative;display:flex!important;flex-direction:column;align-items:center;justify-content:flex-start;gap:12px;width:100%;min-width:0;min-height:194px;border:2px solid hsl(var(--border));border-radius:12px;padding:24px;background:hsl(var(--card));color:hsl(var(--foreground));font:inherit;font-size:14px;line-height:1.45;text-align:center;cursor:pointer;transition:border-color .15s,background-color .15s,box-shadow .15s}',
|
|
89
|
+
'.netflix-theme-option:hover:not([data-selected="true"]){border-color:color-mix(in srgb,hsl(var(--muted-foreground)) 30%,hsl(var(--border)))}',
|
|
90
|
+
'.netflix-theme-option[data-selected="true"]{border-color:hsl(var(--primary));background:color-mix(in srgb,hsl(var(--primary)) 5%,hsl(var(--card)));box-shadow:0 0 0 1px color-mix(in srgb,hsl(var(--primary)) 20%,transparent)}',
|
|
91
|
+
'.netflix-theme-option:focus-visible{outline:2px solid hsl(var(--ring));outline-offset:3px}',
|
|
92
|
+
'.netflix-theme-option-icon{display:flex;flex:0 0 auto;width:64px;height:64px;align-items:center;justify-content:center;border-radius:12px;background:hsl(var(--muted));color:hsl(var(--muted-foreground))}',
|
|
93
|
+
'.netflix-theme-option-icon svg{width:32px;height:32px}',
|
|
94
|
+
'.netflix-theme-option[data-selected="true"] .netflix-theme-option-icon{background:color-mix(in srgb,hsl(var(--primary)) 10%,hsl(var(--card)));color:hsl(var(--primary))}',
|
|
95
|
+
'.netflix-theme-option-copy{display:flex;flex-direction:column;align-items:center;gap:4px}',
|
|
96
|
+
'.netflix-theme-option-title{font-size:14px;font-weight:600}',
|
|
97
|
+
'.netflix-theme-option[data-selected="true"] .netflix-theme-option-title{color:hsl(var(--primary))}',
|
|
98
|
+
'.netflix-theme-option-description{font-size:12px;line-height:1.45;color:hsl(var(--muted-foreground))}',
|
|
99
|
+
'.netflix-theme-option-check{position:absolute;top:12px;right:12px;display:none;width:20px;height:20px;color:hsl(var(--primary))}',
|
|
100
|
+
'.netflix-theme-option-check svg{display:block;width:20px;height:20px}',
|
|
101
|
+
'.netflix-theme-option[data-selected="true"] .netflix-theme-option-check{display:block}',
|
|
102
|
+
'.netflix-theme-option-status{margin-top:8px;font-size:12px;color:hsl(var(--destructive));}',
|
|
103
|
+
'.netflix-theme-option-status[hidden]{display:none!important}'
|
|
104
|
+
].join('');
|
|
105
|
+
document.head.appendChild(style);
|
|
106
|
+
state.style = style;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function findRadioGroup(title) {
|
|
110
|
+
var heading = Array.from(document.querySelectorAll('h2')).find(function (node) {
|
|
111
|
+
return node.textContent.trim() === title;
|
|
112
|
+
});
|
|
113
|
+
var node = heading;
|
|
114
|
+
while (node && node !== document.body) {
|
|
115
|
+
var groups = node.querySelectorAll('[role="radiogroup"]');
|
|
116
|
+
if (groups.length === 1) return groups[0];
|
|
117
|
+
node = node.parentElement;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function setCardSelection(card, selected) {
|
|
123
|
+
card.className = (selected ? selectedCardClass : unselectedCardClass) + ' netflix-theme-option';
|
|
124
|
+
card.setAttribute('aria-checked', String(selected));
|
|
125
|
+
card.dataset.selected = String(selected);
|
|
126
|
+
card._netflixIconBox.className = (selected ? selectedIconClass : unselectedIconClass) + ' netflix-theme-option-icon';
|
|
127
|
+
card._netflixTitle.className = 'netflix-theme-option-title';
|
|
128
|
+
card._netflixDescription.className = 'netflix-theme-option-description';
|
|
129
|
+
card._netflixCheck.style.display = selected ? 'block' : 'none';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function createChoiceCard(kind) {
|
|
133
|
+
var option = choices[kind];
|
|
134
|
+
var card = document.createElement('div');
|
|
135
|
+
card.setAttribute('role', 'radio');
|
|
136
|
+
card.setAttribute('aria-label', option.title + ' ' + option.description);
|
|
137
|
+
card.setAttribute('aria-checked', 'false');
|
|
138
|
+
card.dataset.selected = 'false';
|
|
139
|
+
card.setAttribute('tabindex', '0');
|
|
140
|
+
card.dataset.netflixOption = kind;
|
|
141
|
+
card.className = unselectedCardClass + ' netflix-theme-option';
|
|
142
|
+
|
|
143
|
+
var radio = document.createElement('span');
|
|
144
|
+
radio.className = 'sr-only';
|
|
145
|
+
card.appendChild(radio);
|
|
146
|
+
|
|
147
|
+
var iconBox = document.createElement('div');
|
|
148
|
+
iconBox.className = unselectedIconClass;
|
|
149
|
+
iconBox.innerHTML = '<svg class="h-8 w-8" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5" aria-hidden="true">' + option.icon + '</svg>';
|
|
150
|
+
card.appendChild(iconBox);
|
|
151
|
+
|
|
152
|
+
var text = document.createElement('div');
|
|
153
|
+
text.className = 'netflix-theme-option-copy';
|
|
154
|
+
var title = document.createElement('div');
|
|
155
|
+
title.className = unselectedTitleClass;
|
|
156
|
+
title.textContent = option.title;
|
|
157
|
+
var description = document.createElement('div');
|
|
158
|
+
description.className = 'netflix-theme-option-description';
|
|
159
|
+
description.textContent = option.description;
|
|
160
|
+
text.append(title, description);
|
|
161
|
+
card.appendChild(text);
|
|
162
|
+
|
|
163
|
+
var check = document.createElement('div');
|
|
164
|
+
check.className = 'netflix-theme-option-check';
|
|
165
|
+
check.style.display = 'none';
|
|
166
|
+
check.innerHTML = '<svg class="h-5 w-5 text-primary" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg>';
|
|
167
|
+
card.appendChild(check);
|
|
168
|
+
card._netflixIconBox = iconBox;
|
|
169
|
+
card._netflixTitle = title;
|
|
170
|
+
card._netflixDescription = description;
|
|
171
|
+
card._netflixCheck = check;
|
|
172
|
+
|
|
173
|
+
function activate(event) {
|
|
174
|
+
if (event) { event.preventDefault(); event.stopPropagation(); }
|
|
175
|
+
selectPluginChoice(kind, option.value);
|
|
176
|
+
}
|
|
177
|
+
card.addEventListener('click', activate);
|
|
178
|
+
card.addEventListener('keydown', function (event) {
|
|
179
|
+
if (event.key === 'Enter' || event.key === ' ') activate(event);
|
|
180
|
+
});
|
|
181
|
+
return card;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function ensureStatus(group) {
|
|
185
|
+
if (!group || !group.parentElement) return;
|
|
186
|
+
var status = group.parentElement.querySelector('[data-netflix-option-status="' + group.dataset.netflixKind + '"]');
|
|
187
|
+
if (!status) {
|
|
188
|
+
status = document.createElement('div');
|
|
189
|
+
status.className = 'netflix-theme-option-status';
|
|
190
|
+
status.dataset.netflixOptionStatus = group.dataset.netflixKind;
|
|
191
|
+
status.setAttribute('role', 'status');
|
|
192
|
+
status.hidden = true;
|
|
193
|
+
group.insertAdjacentElement('afterend', status);
|
|
194
|
+
}
|
|
195
|
+
return status;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function showSaveError(group, error) {
|
|
199
|
+
var status = ensureStatus(group);
|
|
200
|
+
if (!status) return;
|
|
201
|
+
status.textContent = error ? error.message : '';
|
|
202
|
+
status.hidden = !error;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function setNativeRadioSelection(group, overridden) {
|
|
206
|
+
if (!group) return;
|
|
207
|
+
Array.from(group.children).forEach(function (card) {
|
|
208
|
+
if (card.tagName !== 'LABEL') return;
|
|
209
|
+
var radio = card.querySelector('button[data-slot="radio-group-item"]');
|
|
210
|
+
if (!radio) return;
|
|
211
|
+
if (overridden) {
|
|
212
|
+
if (!Object.prototype.hasOwnProperty.call(card.dataset, 'netflixOriginalAria')) {
|
|
213
|
+
card.dataset.netflixOriginalAria = radio.hasAttribute('aria-checked') ? radio.getAttribute('aria-checked') : '__none__';
|
|
214
|
+
card.dataset.netflixOriginalState = radio.hasAttribute('data-state') ? radio.getAttribute('data-state') : '__none__';
|
|
215
|
+
}
|
|
216
|
+
radio.setAttribute('aria-checked', 'false');
|
|
217
|
+
radio.setAttribute('data-state', 'unchecked');
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (Object.prototype.hasOwnProperty.call(card.dataset, 'netflixOriginalAria')) {
|
|
221
|
+
if (card.dataset.netflixOriginalAria === '__none__') radio.removeAttribute('aria-checked');
|
|
222
|
+
else radio.setAttribute('aria-checked', card.dataset.netflixOriginalAria);
|
|
223
|
+
if (card.dataset.netflixOriginalState === '__none__') radio.removeAttribute('data-state');
|
|
224
|
+
else radio.setAttribute('data-state', card.dataset.netflixOriginalState);
|
|
225
|
+
delete card.dataset.netflixOriginalAria;
|
|
226
|
+
delete card.dataset.netflixOriginalState;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function syncGroup(kind, group) {
|
|
232
|
+
if (!group) return;
|
|
233
|
+
var option = choices[kind];
|
|
234
|
+
group.dataset.netflixKind = kind;
|
|
235
|
+
group.classList.add(option.gridClass);
|
|
236
|
+
var card = group.querySelector('[data-netflix-option="' + kind + '"]');
|
|
237
|
+
if (!card) {
|
|
238
|
+
card = createChoiceCard(kind);
|
|
239
|
+
group.appendChild(card);
|
|
240
|
+
}
|
|
241
|
+
var selected = state.home[kind] === option.value;
|
|
242
|
+
setCardSelection(card, selected);
|
|
243
|
+
group.classList.toggle('netflix-theme-plugin-selected', selected);
|
|
244
|
+
setNativeRadioSelection(group, selected);
|
|
245
|
+
ensureStatus(group);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function syncPage() {
|
|
249
|
+
if (!state.enabled || !state.configLoaded || !isSettingsRoute()) {
|
|
250
|
+
cleanupUi();
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
ensureStyle();
|
|
254
|
+
syncGroup('storefrontTemplate', findRadioGroup(choices.storefrontTemplate.groupTitle));
|
|
255
|
+
syncGroup('productLayout', findRadioGroup(choices.productLayout.groupTitle));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function cleanupUi() {
|
|
259
|
+
document.querySelectorAll('[data-netflix-option]').forEach(function (node) { node.remove(); });
|
|
260
|
+
document.querySelectorAll('.netflix-theme-store-grid,.netflix-theme-layout-grid').forEach(function (group) {
|
|
261
|
+
setNativeRadioSelection(group, false);
|
|
262
|
+
group.classList.remove('netflix-theme-store-grid', 'netflix-theme-layout-grid', 'netflix-theme-plugin-selected');
|
|
263
|
+
delete group.dataset.netflixKind;
|
|
264
|
+
});
|
|
265
|
+
document.querySelectorAll('[data-netflix-option-status]').forEach(function (node) { node.remove(); });
|
|
266
|
+
if (state.style) { state.style.remove(); state.style = null; }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function persistHome() {
|
|
270
|
+
return request('/plugins/' + pluginId + '/env', {
|
|
271
|
+
method: 'POST',
|
|
272
|
+
body: JSON.stringify({ values: { [configKey]: JSON.stringify(state.home) } })
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function selectPluginChoice(kind, value) {
|
|
277
|
+
var option = choices[kind];
|
|
278
|
+
var previous = state.home[kind] || '';
|
|
279
|
+
state.home[kind] = value;
|
|
280
|
+
syncPage();
|
|
281
|
+
persistHome().catch(function (error) {
|
|
282
|
+
state.home[kind] = previous;
|
|
283
|
+
syncPage();
|
|
284
|
+
showSaveError(findRadioGroup(option.groupTitle), error);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function clearPluginChoiceForCoreRadio(event) {
|
|
289
|
+
if (!state.enabled) return;
|
|
290
|
+
var target = event.target;
|
|
291
|
+
if (!target || !target.closest) return;
|
|
292
|
+
var custom = target.closest('[data-netflix-option]');
|
|
293
|
+
if (custom) return;
|
|
294
|
+
var radio = target.closest('button[data-slot="radio-group-item"]');
|
|
295
|
+
if (!radio) {
|
|
296
|
+
var label = target.closest('label');
|
|
297
|
+
radio = label && label.querySelector('button[data-slot="radio-group-item"]');
|
|
298
|
+
}
|
|
299
|
+
var group = radio && radio.closest('[role="radiogroup"]');
|
|
300
|
+
var kind = group && group.dataset.netflixKind;
|
|
301
|
+
if (!kind || !state.home[kind]) return;
|
|
302
|
+
state.home[kind] = '';
|
|
303
|
+
syncPage();
|
|
304
|
+
persistHome().catch(function (error) {
|
|
305
|
+
state.home[kind] = choices[kind].value;
|
|
306
|
+
syncPage();
|
|
307
|
+
showSaveError(group, error);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async function loadSettings() {
|
|
312
|
+
if (state.loadingConfig || state.configLoaded) return;
|
|
313
|
+
state.loadingConfig = true;
|
|
314
|
+
try {
|
|
315
|
+
var payload = await request('/plugins/' + pluginId + '/env');
|
|
316
|
+
var field = (payload.fields || []).find(function (item) { return item.key === configKey; });
|
|
317
|
+
var home = JSON.parse(field && field.value || '{}');
|
|
318
|
+
state.home = home && typeof home === 'object' && !Array.isArray(home) ? home : {};
|
|
319
|
+
state.configLoaded = true;
|
|
320
|
+
syncPage();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
console.warn('[Netflix Theme Admin]', error);
|
|
323
|
+
} finally {
|
|
324
|
+
state.loadingConfig = false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async function checkRuntime() {
|
|
329
|
+
if (state.checking) return;
|
|
330
|
+
state.checking = true;
|
|
331
|
+
try {
|
|
332
|
+
var response = await fetch(apiBase + '/plugins/public-assets?context=admin', { cache: 'no-store' });
|
|
333
|
+
if (!response.ok) return;
|
|
334
|
+
var registry = await response.json();
|
|
335
|
+
var enabled = Array.isArray(registry.assets) && registry.assets.some(function (plugin) {
|
|
336
|
+
return plugin && plugin.id === pluginId;
|
|
337
|
+
});
|
|
338
|
+
state.enabled = Boolean(enabled);
|
|
339
|
+
if (!state.enabled) {
|
|
340
|
+
state.configLoaded = false;
|
|
341
|
+
cleanupUi();
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (!isSettingsRoute()) {
|
|
345
|
+
cleanupUi();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
await loadSettings();
|
|
349
|
+
syncPage();
|
|
350
|
+
} catch (_error) {
|
|
351
|
+
// Keep the currently rendered controls during transient registry failures.
|
|
352
|
+
} finally {
|
|
353
|
+
state.checking = false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (!isAdminRoute()) return;
|
|
358
|
+
var observerTimer = null;
|
|
359
|
+
state.observer = new MutationObserver(function () {
|
|
360
|
+
if (!state.enabled || !state.configLoaded) return;
|
|
361
|
+
if (observerTimer) clearTimeout(observerTimer);
|
|
362
|
+
observerTimer = setTimeout(syncPage, 60);
|
|
363
|
+
});
|
|
364
|
+
state.observer.observe(document.body, { childList: true, subtree: true });
|
|
365
|
+
document.addEventListener('click', clearPluginChoiceForCoreRadio, true);
|
|
366
|
+
window.addEventListener('popstate', syncPage);
|
|
367
|
+
window.addEventListener('hashchange', syncPage);
|
|
368
|
+
checkRuntime();
|
|
369
|
+
setInterval(checkRuntime, 2500);
|
|
370
|
+
})();
|