Repository navigation
Expand file tree
/
Copy pathsafety.html
More file actions
266 lines (256 loc) · 16.2 KB
/
Copy pathsafety.html
File metadata and controls
266 lines (256 loc) · 16.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<meta name="referrer" content="no-referrer">
<title>Content controls · LoungeFeed</title>
<link rel="icon" href="assets/icons/icon-32.png" sizes="32x32" type="image/png">
<link rel="apple-touch-icon" href="assets/icons/icon-180.png">
<link rel="manifest" href="site.webmanifest">
<style>
:root { color-scheme: dark; --bg:#07111f; --panel:#101d30; --panel-soft:#16263c; --text:#f4f7fb; --muted:#adbbcf; --line:rgba(255,255,255,.12); --accent:#6eb7ff; --warning:#ffd166; --success:#73d9aa; --error:#ff9b9b; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { min-height:100vh; margin:0; display:grid; place-items:center; background:radial-gradient(circle at 80% 0%,#17375c 0,transparent 42%),var(--bg); color:var(--text); font:16px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
main { width:min(660px,calc(100% - 36px)); padding:42px 0; }
.brand { display:flex; gap:11px; align-items:center; color:var(--text); font-size:18px; font-weight:760; text-decoration:none; }
.logo { width:36px; height:36px; border-radius:11px; object-fit:cover; }
.eyebrow { margin-top:46px; color:var(--accent); font-size:13px; font-weight:750; letter-spacing:.12em; text-transform:uppercase; }
h1 { margin:10px 0 12px; font-size:clamp(37px,8vw,58px); line-height:1.05; letter-spacing:-.045em; }
.lead,.note { color:var(--muted); font-size:18px; }
.card { margin-top:30px; padding:28px; border:1px solid var(--line); border-radius:22px; background:rgba(16,29,48,.9); box-shadow:0 24px 80px rgba(0,0,0,.26); }
h2 { margin:0 0 12px; font-size:21px; }
.check { display:flex; align-items:flex-start; gap:12px; margin:24px 0; color:var(--muted); }
.check input { width:21px; height:21px; margin:3px 0 0; accent-color:var(--accent); }
.toggle-row { display:flex; align-items:center; justify-content:space-between; gap:22px; padding:18px 0; border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.toggle-row strong { display:block; color:var(--text); }
.toggle { position:relative; width:58px; height:34px; flex:none; }
.toggle input { opacity:0; width:0; height:0; }
.toggle input:disabled + .slider { opacity:.55; cursor:wait; }
.slider { position:absolute; inset:0; cursor:pointer; border-radius:999px; background:rgba(255,255,255,.17); transition:.18s; }
.slider::before { content:""; position:absolute; width:26px; height:26px; left:4px; top:4px; border-radius:50%; background:white; transition:.18s; }
input:checked + .slider { background:rgba(115,217,170,.8); }
input:checked + .slider::before { transform:translateX(24px); }
button { margin-top:24px; padding:12px 18px; border:0; border-radius:12px; background:var(--accent); color:#07111f; font:inherit; font-weight:800; cursor:pointer; }
button:disabled { opacity:.55; cursor:wait; }
.status { min-height:25px; margin:16px 0 0; color:var(--muted); }
.status.success { color:var(--success); } .status.error { color:var(--error); }
.notice { margin-top:19px; padding:14px 16px; border-left:3px solid var(--warning); border-radius:8px; background:rgba(255,209,102,.08); color:var(--muted); font-size:14px; }
dialog { width:min(510px,calc(100% - 36px)); border:1px solid var(--line); border-radius:20px; padding:28px; color:var(--text); background:var(--panel); box-shadow:0 24px 80px rgba(0,0,0,.5); }
dialog::backdrop { background:rgba(0,0,0,.68); }
dialog h2 { margin-bottom:10px; } dialog p { color:var(--muted); }
.dialog-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:12px; margin-top:22px; }
.secondary { background:transparent; color:var(--text); border:1px solid var(--line); }
footer { margin-top:32px; color:var(--muted); font-size:14px; }
footer a { color:inherit; }
</style>
</head>
<body>
<main>
<a class="brand" href="index.html"><img class="logo" src="assets/icons/icon-192.png" alt=""><span>LoungeFeed</span></a>
<div class="eyebrow">Apple TV content controls</div>
<h1>Content controls</h1>
<p class="lead">This page manages content controls for the Apple TV that displayed this code. LoungeFeed filters some posts by default.</p>
<section class="card" id="connection" aria-live="polite" aria-busy="true">
<h2 id="connection-title">Preparing content controls</h2>
<p class="note" id="connection-message">Checking the secure link for your Apple TV. If this message does not change, open the scanned link in Safari or another browser with JavaScript enabled.</p>
<button id="retry" type="button" hidden>Try again</button>
<noscript><p class="notice">JavaScript is disabled in this browser. Enable JavaScript, then reopen the complete link from the code on your Apple TV.</p></noscript>
</section>
<section class="card" id="content" hidden>
<h2>Filtered posts</h2>
<p class="note">Some connected sources flag posts that may not be suitable for every viewer. Enabling this preference allows that Apple TV to offer an additional local screen-protection step.</p>
<label class="check"><input id="age-confirmation" type="checkbox" disabled><span>I confirm that I am 18 or older and want to manage these controls.</span></label>
<div class="toggle-row">
<div><strong>Show filtered posts on Apple TV</strong><span class="note">The Apple TV keeps posts filtered until its local protection is completed.</span></div>
<label class="toggle" aria-label="Show filtered posts on Apple TV"><input id="preference" type="checkbox" disabled><span class="slider"></span></label>
</div>
<p id="pro-note" class="notice" hidden>A valid Pro membership is required for this preference to take effect. Without it, posts remain filtered.</p>
<button id="save" type="button" disabled>Save controls</button>
<p id="status" class="status" role="status" aria-live="polite"></p>
</section>
<section class="card" id="unavailable" hidden>
<h2 id="unavailable-title">This code is no longer active</h2>
<p class="note" id="unavailable-message">Return to LoungeFeed on Apple TV, close the code screen, then open Content controls again to display a new code. Scan it within 10 minutes.</p>
</section>
<footer><a href="privacy.html">Privacy Policy</a> · LoungeFeed stores only this Apple TV’s random preference identifier and the selected setting. It does not receive your feed content, media, social credentials, or Apple Account information.</footer>
</main>
<dialog id="pro-dialog" aria-labelledby="pro-dialog-title">
<h2 id="pro-dialog-title">Before you continue</h2>
<p>This preference only takes effect on an Apple TV with a valid Pro membership. If that membership is not active, posts remain filtered.</p>
<div class="dialog-actions"><button class="secondary" id="keep-masked" type="button">Keep filtering</button><button id="enable-anyway" type="button">Enable controls</button></div>
</dialog>
<script>
(() => {
const parameters = new URLSearchParams(location.search);
const exploreSession = parameters.get("exploreSession");
const endpoint = exploreSession
? "https://loungefeed-support.loungefeed.workers.dev/v1/explore-controls/web-session"
: "https://loungefeed-support.loungefeed.workers.dev/v1/content-preferences/web-session";
const session = exploreSession || parameters.get("session");
const connection = document.getElementById("connection");
const connectionTitle = document.getElementById("connection-title");
const connectionMessage = document.getElementById("connection-message");
const retry = document.getElementById("retry");
const content = document.getElementById("content");
const unavailable = document.getElementById("unavailable");
const unavailableTitle = document.getElementById("unavailable-title");
const unavailableMessage = document.getElementById("unavailable-message");
const age = document.getElementById("age-confirmation");
const preference = document.getElementById("preference");
const save = document.getElementById("save");
const statusText = document.getElementById("status");
const proNote = document.getElementById("pro-note");
const dialog = document.getElementById("pro-dialog");
const requestTimeoutMs = 12_000;
let sessionInfo = null;
let isLoading = false;
let isSaving = false;
function url() { return `${endpoint}?session=${encodeURIComponent(session || "")}`; }
function showStatus(message, kind = "") { statusText.className = `status ${kind}`; statusText.textContent = message; }
function setControlsDisabled(disabled) { age.disabled = disabled; preference.disabled = disabled; save.disabled = disabled; }
function setUnavailable(missing = false) {
sessionInfo = null;
setControlsDisabled(true);
connection.hidden = true;
connection.setAttribute("aria-busy", "false");
content.hidden = true;
unavailable.hidden = false;
unavailableTitle.textContent = missing ? "Scan a new code from your Apple TV" : "This code is no longer active";
unavailableMessage.textContent = missing
? "This link is missing a valid secure code. Return to LoungeFeed on Apple TV, close the code screen, then open Content controls again. Scan the new code and open the complete link."
: "Return to LoungeFeed on Apple TV, close the code screen, then open Content controls again to display a new code. Scan it within 10 minutes.";
}
function setConnectionError(error) {
sessionInfo = null;
setControlsDisabled(true);
content.hidden = true;
unavailable.hidden = true;
connection.hidden = false;
connection.setAttribute("aria-busy", "false");
connectionTitle.textContent = "Could not load content controls";
connectionMessage.textContent = error && error.message === "request_timeout"
? "The connection took too long. Check your internet connection and try again. If it still fails, reopen the complete scanned link in Safari or another browser."
: "The content-controls service could not be reached or returned an unexpected response. Check your internet connection and try again. If the code expires, scan a new one from your Apple TV.";
retry.hidden = false;
}
function isInactiveSession(error) {
return Boolean(error && (error.httpStatus === 410 || (error.httpStatus === 400 && error.message === "invalid_session")));
}
// Bound both the connection and response-body read. Some mobile networks
// leave fetch pending instead of rejecting it; abort alone is not enough
// for browsers that do not support AbortController or ignore cancellation.
async function request(options = {}) {
const controller = typeof AbortController === "function" ? new AbortController() : null;
let timer;
const timeout = new Promise((resolve, reject) => {
timer = setTimeout(() => {
reject(new Error("request_timeout"));
if (controller) controller.abort();
}, requestTimeoutMs);
});
const operation = (async () => {
const response = await fetch(url(), {
...options,
cache: "no-store",
referrerPolicy: "no-referrer",
...(controller ? { signal: controller.signal } : {}),
});
let result;
try { result = await response.json(); } catch { throw new Error("invalid_response"); }
if (!response.ok) {
const error = new Error(result && result.error || "service_unavailable");
error.httpStatus = response.status;
throw error;
}
return result;
})();
try { return await Promise.race([operation, timeout]); }
finally { clearTimeout(timer); }
}
async function load() {
if (isLoading || isSaving) return;
if (!session || !/^[A-Za-z0-9_-]{40,128}$/.test(session)) return setUnavailable(true);
isLoading = true;
sessionInfo = null;
setControlsDisabled(true);
content.hidden = true;
unavailable.hidden = true;
connection.hidden = false;
connection.setAttribute("aria-busy", "true");
connectionTitle.textContent = "Loading content controls…";
connectionMessage.textContent = "Connecting securely to the content-controls service. This should take only a few seconds.";
retry.hidden = true;
retry.disabled = true;
save.textContent = "Save controls";
showStatus("");
try {
const result = await request();
if (!result || typeof result.enabled !== "boolean" || typeof result.proEligible !== "boolean") {
throw new Error("invalid_response");
}
if (exploreSession && result.demoMode !== true) throw new Error("invalid_response");
if (exploreSession) {
document.querySelector("h1").textContent = "Explore sample controls";
const description = document.querySelector(".lead");
if (description) description.textContent = "These temporary controls affect fictional Explore content only. Your normal Apple TV preferences remain unchanged. This session expires after 10 minutes.";
document.querySelector("footer").textContent = "Explore sample session · No Apple Account or social-service information is used. This temporary session expires after 10 minutes.";
document.querySelector("#pro-dialog p").textContent = "This preference affects fictional Explore content only. Complete the sample PIN step on Apple TV to reveal the harmless marked sample. No purchase is required.";
}
sessionInfo = result;
connection.hidden = true;
connection.setAttribute("aria-busy", "false");
content.hidden = false;
preference.checked = result.enabled === true;
proNote.hidden = result.proEligible === true;
setControlsDisabled(false);
} catch (error) {
if (isInactiveSession(error)) setUnavailable();
else setConnectionError(error);
} finally {
isLoading = false;
retry.disabled = false;
}
}
async function savePreference() {
if (!sessionInfo || isLoading || isSaving) return;
if (!age.checked) { showStatus("Confirm that you are 18 or older before saving these controls.", "error"); return; }
isSaving = true;
setControlsDisabled(true);
showStatus("Saving controls…");
try {
const result = await request({
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ ageConfirmed: true, preference: preference.checked ? "enabled" : "disabled" }),
});
if (!result || result.enabled !== preference.checked) throw new Error("invalid_response");
// A successful save consumes this single-use session on the server.
sessionInfo = null;
save.textContent = "Saved";
showStatus("Saved. Return to LoungeFeed on Apple TV to continue. To make another change, scan a new code.", "success");
} catch (error) {
if (isInactiveSession(error)) setUnavailable();
else showStatus("Could not confirm that your controls were saved. Check your internet connection and try saving again.", "error");
} finally {
isSaving = false;
if (sessionInfo) setControlsDisabled(false);
}
}
retry.addEventListener("click", load);
save.addEventListener("click", () => {
if (!sessionInfo || isLoading || isSaving) return;
if (!age.checked) { showStatus("Confirm that you are 18 or older before saving these controls.", "error"); return; }
if (!preference.checked) { savePreference(); return; }
if (typeof dialog.showModal === "function") dialog.showModal();
else if (window.confirm("This preference only takes effect with a valid Pro membership. Enable controls?")) savePreference();
});
document.getElementById("keep-masked").addEventListener("click", () => { preference.checked = false; dialog.close(); });
document.getElementById("enable-anyway").addEventListener("click", () => { dialog.close(); savePreference(); });
load();
})();
</script>
</body>
</html>