aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-13 05:29:09 +0000
committerAdam Soltys <[email protected]>2026-10-13 05:29:09 +0000
commitc423cf3b79b088e542709267002b7db27b1a83ff (patch)
tree410893d3d720f50c8f32fc9478ab07962323f820
parent6488a0a687144e217f71ab1c7a768613b0f17e58 (diff)
downloadcoinosv3-c423cf3b79b088e542709267002b7db27b1a83ff.tar.gz
coinosv3-c423cf3b79b088e542709267002b7db27b1a83ff.zip
Feed video: fewer "To exit full screen" notices, and a YouTube clip takes one tap. Adam: Chrome's "v3.coinos.io – To exit full screen, drag from the top and touch the back button" shows every time, and a YouTube clip needs its own small full-screen icon. The notice is Chrome's, put up whenever a page goes full screen; a page can't turn it off, so the app goes full screen less. In the installed app (display-mode standalone, or opened from an android-app:// referrer) there is no address bar and the pager already fills the window, so it no longer goes full screen: a wide clip asks the screen to turn without it, and only if that's refused (the browser may allow turning only in full screen) goes full screen — the notice then, but the clip on its side; the screen is let go past that clip, or on closing. A browser tab goes full screen as before. A feed clip's own control bar loses its full-screen button (controlslist=nofullscreen): a tap on the clip is the way, into the pager. YouTube: the player's taps never reach the page, so a layer over a playing clip's picture takes them, leaving YouTube's control bar along the bottom to YouTube; one tap on it — or on the still — plays with sound and takes the clip's box full screen, turned on its side (unMute + playVideo through the iframe API for a player autoplaying muted); full screen the layer steps aside, so all of YouTube's controls are there. YouTube can only fill the screen through Chrome's full screen, so its notice still shows there. tools/fullscreen-notice-test.js (installed app: no full screen, the screen turned and let go, the fallback when turning is refused; no full-screen button on feed clips); tools/youtube-tap-test.js (YouTube stood in for: autoplaying muted, a tap on the control bar stays YouTube's, one tap full screen with unMute and playVideo, the layer aside full screen and back after; with Data Saver, the still to full screen with sound); video-unmute-test stubs ui for its slice of videoNode.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPw21NEpWeTGu6swVASmBt
-rw-r--r--src/features/messages.js61
-rw-r--r--src/style.css6
-rw-r--r--tools/fullscreen-notice-test.js126
-rw-r--r--tools/video-unmute-test.js1
-rw-r--r--tools/youtube-tap-test.js110
5 files changed, 294 insertions, 10 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 6e977af..b09aa17 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -7615,7 +7615,10 @@ export function messagesFeature(ctx) {
// play button: no seek bar, no sound button. Without autoplay the
// player's own controls are the way in, so they stay.
const idle = autoplayOk() && !wokeClips.has(url);
- const v = h('video', { src: playSrc(url), class: 'note-video', controls: idle ? undefined : true, poster: videoThumbs.get(url) || (videoInfo.get(url) || {}).image || serverThumb(url),
+ // In the feed a tap on the clip opens the pager, so the player's own
+ // full-screen button (Chrome's full screen: no next clip, and its notice)
+ // is left off its bar there.
+ const v = h('video', { src: playSrc(url), class: 'note-video', controls: idle ? undefined : true, controlslist: ui.chatOpen && ui.msgView === 'feed' && !ui.noteThread && !ui.profilePk ? 'nofullscreen' : undefined, poster: videoThumbs.get(url) || (videoInfo.get(url) || {}).image || serverThumb(url),
preload: 'none', playsinline: true, muted: loud ? undefined : true,
style: stable ? videoBoxStyle(feedMedia(url)) : undefined,
// learned now, used by the next paint of any row with this clip
@@ -7741,27 +7744,44 @@ export function messagesFeature(ctx) {
f.allowFullscreen = true;
f.onload = () => { try { f.contentWindow.postMessage(JSON.stringify({ event: 'listening', id: vid }), '*'); } catch {} };
box.append(f);
+ // a tap on the picture is ours, not the player's (whose taps the page
+ // never sees): it takes the clip full screen — YouTube's own control
+ // bar along the bottom stays YouTube's. Full screen, this steps aside.
+ box.append(h('div', { class: 'yt-shield', 'aria-hidden': 'true' }));
if (muted) {
let on = false;
const btn = soundBtn(() => { on = !on; btn.setSound(on); post(box, on ? 'unMute' : 'mute'); if (on) post(box, 'playVideo'); });
+ box._soundOn = () => { on = true; btn.setSound(true); };
box.append(btn);
}
};
- const frame = h('div', { class: 'yt-embed' },
+ // One tap, as with any clip in a post: it plays, with sound, full screen
+ // (turned on its side). The still loads the player first; a player
+ // already going (autoplayed, muted) is unmuted and carried on.
+ const full = (box) => {
+ const go = box.requestFullscreen || box.webkitRequestFullscreen;
+ if (!go) return;
+ Promise.resolve(go.call(box, { navigationUI: 'hide' }))
+ .then(() => screen.orientation?.lock?.('landscape').catch(() => {})).catch(() => {});
+ };
+ const tapped = (e) => {
+ if (e.target.closest('.yt-open, .vid-sound, iframe')) return;
+ e.stopPropagation(); e.preventDefault();
+ const box = e.currentTarget;
+ if (!box.dataset.playing) load(box, false); // a tap means sound
+ else { post(box, 'unMute'); post(box, 'playVideo'); if (box._soundOn) box._soundOn(); }
+ full(box);
+ };
+ const frame = h('div', { class: 'yt-embed', onClick: tapped },
h('img', {
class: 'yt-poster', loading: 'lazy', alt: '',
src: !feedPaint || feedMedia('https://i.ytimg.com/vi/' + vid + '/hqdefault.jpg')
? 'https://i.ytimg.com/vi/' + vid + '/hqdefault.jpg' : undefined,
onError: (e) => { e.target.style.display = 'none'; },
}),
+ // (its tap is the box's: play, full screen)
h('button', {
- class: 'yt-play', 'aria-label': t('playVideo'), title: t('playVideo'),
- onClick: (e) => {
- e.stopPropagation();
- const box = e.currentTarget.parentElement;
- if (!box || box.dataset.playing) return;
- load(box, false); // a tap means sound
- },
+ class: 'yt-play', type: 'button', 'aria-label': t('playVideo'), title: t('playVideo'),
}, h('span', { style: 'display:flex', html: '<svg width="30" height="30" viewBox="0 0 24 24" fill="currentColor" style="display:block"><path d="M8 5v14l11-7z"/></svg>' })),
h('a', {
class: 'yt-open', href: url, target: '_blank', rel: 'noopener noreferrer',
@@ -11770,7 +11790,27 @@ export function messagesFeature(ctx) {
} catch { return false; }
}
let pagerFs = false; // the pager put the page full screen (and so takes it back out)
+ let pagerLock = false; // the pager turned the screen (and so lets it go)
+ // The installed app (the Play/Zapstore build, or a home-screen install)
+ // has no address bar: the pager already fills its window. Going full
+ // screen there only hid the system bars, and every time it did Chrome put
+ // up its "To exit full screen, drag from the top…" notice, which a page
+ // can't turn off. So there it doesn't: a wide clip asks the screen to turn
+ // without it, and goes full screen only if that's refused (the browser
+ // allows turning only in full screen) — the notice then, but the clip on
+ // its side.
+ const installedApp = () => {
+ try { return matchMedia('(display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui)').matches || document.referrer.startsWith('android-app://'); } catch { return false; }
+ };
function pagerFullscreen(wide) {
+ if (installedApp()) {
+ if (!wide || !screen.orientation?.lock) return;
+ screen.orientation.lock('landscape').then(() => { if (ui.mediaPager) pagerLock = true; else screen.orientation.unlock?.(); }, () => pagerGoFullscreen(true));
+ return;
+ }
+ pagerGoFullscreen(wide);
+ }
+ function pagerGoFullscreen(wide) {
const d = document.documentElement;
const go = d.requestFullscreen || d.webkitRequestFullscreen;
if (!go || fsElement()) return;
@@ -11782,6 +11822,7 @@ export function messagesFeature(ctx) {
}
const exitFs = () => { try { (document.exitFullscreen || document.webkitExitFullscreen || (() => {})).call(document)?.catch?.(() => {}); } catch {} };
function pagerUnFullscreen() {
+ if (pagerLock) { pagerLock = false; try { screen.orientation?.unlock?.(); } catch {} }
if (!pagerFs) return;
pagerFs = false;
try { screen.orientation?.unlock?.(); } catch {}
@@ -12332,7 +12373,7 @@ export function messagesFeature(ctx) {
if (pager.cur && pager.cur !== e.target) {
const v = pager.cur.querySelector('video.mp-media'); if (v) v.pause();
// past the clip it opened on, the screen follows the phone again
- if (pagerFs) { try { screen.orientation?.unlock?.(); } catch {} }
+ if (pagerFs || pagerLock) { pagerLock = false; try { screen.orientation?.unlock?.(); } catch {} }
if (pager.fromFeed && video) el.classList.remove('show');
}
pager.cur = e.target;
diff --git a/src/style.css b/src/style.css
index e66d756..e03ff14 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1010,6 +1010,12 @@ html.no-scroll { overflow: hidden; scrollbar-gutter: auto; }
padding: 4px 7px; border-radius: 8px; background: rgba(18, 18, 18, .6); text-decoration: none;
}
.yt-open:hover { background: rgba(18, 18, 18, .85); text-decoration: none; }
+/* over a playing clip: a tap takes it full screen; YouTube's control bar
+ along the bottom is left uncovered, and full screen it all is */
+.yt-shield { position: absolute; left: 0; right: 0; top: 0; bottom: 52px; z-index: 1; cursor: pointer; }
+.yt-embed:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
+.yt-embed:fullscreen .yt-shield { display: none; }
+.yt-embed:fullscreen iframe { object-fit: contain; }
/* A link, as the card its page describes: picture on top, title, a line,
the site. The whole card is the link. */
.link-card {
diff --git a/tools/fullscreen-notice-test.js b/tools/fullscreen-notice-test.js
new file mode 100644
index 0000000..2861439
--- /dev/null
+++ b/tools/fullscreen-notice-test.js
@@ -0,0 +1,126 @@
+// In the installed app (no address bar: the pager already fills the window)
+// the pager doesn't go full screen — every time it did, Chrome put up its
+// "To exit full screen…" notice. A wide clip asks the screen to turn
+// without it; if that's refused, then full screen (the notice, but the clip
+// on its side). In a browser tab it goes full screen as before
+// (feed-video-pager-test). A feed clip's own bar has no full-screen button:
+// a tap on the clip is the way, into the pager.
+// Run: bun tools/fullscreen-notice-test.js
+import puppeteer from './puppeteer.js';
+import { cacheKeyFor } from '../src/wallet.js';
+import { generateSecretKey, getPublicKey, finalizeEvent } from 'nostr-tools/pure';
+import { buildHtml } from '../build.js';
+import { existsSync } from 'node:fs';
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+let ok = true;
+const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; };
+const clip = (name, size) => {
+ const f = '/tmp/coinos-vpager-' + name + '.webm';
+ if (!existsSync(f)) Bun.spawnSync(['ffmpeg', '-y', '-loglevel', 'error', '-f', 'lavfi', '-i', 'testsrc=size=' + size + ':rate=10', '-t', '30', '-c:v', 'libvpx', '-b:v', '100k', f]);
+ return f;
+};
+const CLIPS = { wide: clip('wide', '320x180'), tall: clip('tall', '180x320'), last: clip('last', '240x240') };
+
+const SK = generateSecretKey(), AUTHOR = getPublicKey(SK);
+const now = Math.floor(Date.now() / 1000);
+const post = (content, ago) => finalizeEvent({ kind: 1, created_at: now - ago, tags: [], content }, SK);
+const html = await buildHtml({ minify: true, pwa: false });
+const server = Bun.serve({ port: 0, fetch: (req) => {
+ const path = new URL(req.url).pathname;
+ const m = /^\/(wide|tall|last)\.webm$/.exec(path);
+ if (m) return new Response(Bun.file(CLIPS[m[1]]), { headers: { 'content-type': 'video/webm' } });
+ if (path.startsWith('/punks') || path === '/verify-worker.js') return new Response(Bun.file('dist' + path));
+ return new Response(html, { headers: { 'content-type': 'text/html' } });
+} });
+const U = (n) => server.url.origin + '/' + n + '.webm';
+const seeded = [
+ post('a wide one ' + U('wide'), 100),
+ post('a tall one ' + U('tall'), 200),
+ post('only words here, nothing to watch', 300),
+ post('the last clip ' + U('last'), 400),
+ ...Array.from({ length: 10 }, (_, i) => post('filler ' + i + ' ' + 'lorem ipsum dolor sit amet. '.repeat(5), 500 + i * 60)),
+];
+
+
+async function run(lockOk) {
+ console.log('\n[the installed app, the screen ' + (lockOk ? 'turning' : 'refusing to turn') + ' without full screen]');
+ const ctx = await browser.createBrowserContext(); // storage of its own: a fresh wallet each run
+ const page = await ctx.newPage();
+ await page.evaluateOnNewDocument((ok) => {
+ const Real = window.WebSocket;
+ window.WebSocket = function (...a) { const ws = new Real(...a); const send = ws.send.bind(ws); ws.send = (d) => { try { const m = JSON.parse(d); if (m[0] === 'REQ') { setTimeout(() => ws.dispatchEvent(new MessageEvent('message', { data: JSON.stringify(['EOSE', m[1]]) })), 0); return; } if (m[0] === 'EVENT') return; } catch {} return send(d); }; return ws; };
+ window.WebSocket.prototype = Real.prototype; Object.assign(window.WebSocket, Real);
+ // the installed app: display-mode standalone
+ const mm = window.matchMedia.bind(window);
+ // (only once the test's wallet is made: the first-run screens differ in the app)
+ const on = () => { try { return localStorage.getItem('__standalone') === '1'; } catch { return false; } };
+ window.matchMedia = (q) => (on() && /display-mode:\s*standalone/.test(q) ? { matches: true, media: q, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {} } : mm(q));
+ window.__orient = [];
+ screen.orientation.lock = (o) => { window.__orient.push('lock:' + o + (document.fullscreenElement ? ':fs' : '')); return ok || document.fullscreenElement ? Promise.resolve() : Promise.reject(new DOMException('not allowed', 'NotSupportedError')); };
+ screen.orientation.unlock = () => { window.__orient.push('unlock'); };
+ }, lockOk);
+ const errs = [];
+ page.on('pageerror', (e) => errs.push(String(e)));
+ const click = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t);
+ const waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await page.evaluate(() => document.body.innerText)).toLowerCase().includes(x)) return true; await sleep(250); } return false; };
+ const waitFor = async (fn, arg, ms = 10000) => { for (let i = 0; i < ms / 100; i++) { if (await page.evaluate(fn, arg)) return true; await sleep(100); } return false; };
+ const st = () => page.evaluate(() => ({ open: !!document.querySelector('.media-pager.videos'), fs: !!document.fullscreenElement, orient: window.__orient.slice() }));
+ const openClip = async (word) => {
+ await page.evaluate((w) => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes(w)); r.querySelector('video.note-video').scrollIntoView({ block: 'center' }); }, word);
+ await sleep(400);
+ const at = await page.evaluate((w) => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes(w)); const b = r.querySelector('video.note-video').getBoundingClientRect(); return { x: b.x + b.width * 0.2, y: b.y + b.height * 0.3 }; }, word);
+ await page.mouse.click(at.x, at.y);
+ await waitFor(() => !!document.querySelector('.media-pager.videos'), null, 4000);
+ };
+ try {
+ await page.setViewport({ width: 390, height: 844 });
+ await page.goto(server.url.href, { waitUntil: 'domcontentloaded' });
+ await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest'));
+ await page.reload({ waitUntil: 'domcontentloaded' }); await sleep(400);
+ await click('create a new wallet'); await sleep(600);
+ await page.waitForSelector('.words .w .t');
+ const mn = (await page.$$eval('.words .w .t', (l) => l.map((e) => e.textContent.trim()))).join(' ');
+ await click('skip verification');
+ await waitText('receive', 20000);
+ const base = cacheKeyFor(mn + '\n');
+ await page.evaluate(([k, pk, ns]) => {
+ localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', pk]], c: '', at: Math.floor(Date.now() / 1000) }));
+ localStorage.setItem(k + ':feedNotes', JSON.stringify(ns));
+ localStorage.setItem(k + ':profiles', JSON.stringify({ [pk]: { name: 'Clip Poster', t: Date.now() } }));
+ localStorage.setItem('btc-wallet-feed:' + k, 'following');
+ localStorage.setItem('__standalone', '1');
+ }, [base, AUTHOR, seeded]);
+ await page.reload({ waitUntil: 'domcontentloaded' });
+ await waitText('receive', 20000);
+ await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]').click());
+ await page.waitForSelector('.notes-feed video.note-video', { timeout: 20000 });
+ if (lockOk) check('a feed clip\'s bar has no full-screen button', await waitFor(() => [...document.querySelectorAll('.notes-feed video.note-video')].every((v) => v.getAttribute('controlslist') === 'nofullscreen'), null, 5000));
+ await openClip('a wide one');
+ await sleep(1200);
+ let s = await st();
+ check('a tap on a wide clip opens the pager', s.open);
+ if (lockOk) {
+ check('…not full screen (no notice)', !s.fs, JSON.stringify(s));
+ check('…the screen asked to turn, without full screen', s.orient[0] === 'lock:landscape', JSON.stringify(s.orient));
+ } else {
+ check('…refused, it goes full screen', s.fs, JSON.stringify(s));
+ check('…and turns there', s.orient.includes('lock:landscape:fs'), JSON.stringify(s.orient));
+ }
+ await page.keyboard.press('ArrowDown'); await sleep(1200);
+ check('past it, the screen is let go', (await st()).orient.includes('unlock'), JSON.stringify((await st()).orient));
+ await page.keyboard.press('Escape');
+ check('Escape closes it', await waitFor(() => !document.querySelector('.media-pager') && !document.fullscreenElement, null, 3000));
+ if (lockOk) {
+ const n = (await st()).orient.length;
+ await openClip('a tall one'); await sleep(1200);
+ s = await st();
+ check('a tall clip: the pager, no full screen, the screen left alone', s.open && !s.fs && s.orient.length === n, JSON.stringify(s));
+ await page.keyboard.press('Escape'); await sleep(600);
+ }
+ check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | '));
+ } finally { await ctx.close(); }
+}
+const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] });
+try { await run(true); await run(false); } finally { await browser.close(); server.stop(true); }
+console.log(ok ? '\n✅ the installed app\'s pager skips full screen (and its notice) where it can' : '\n❌ failed');
+process.exit(ok ? 0 : 1);
diff --git a/tools/video-unmute-test.js b/tools/video-unmute-test.js
index 6aef88e..e352c36 100644
--- a/tools/video-unmute-test.js
+++ b/tools/video-unmute-test.js
@@ -21,6 +21,7 @@ const server = Bun.serve({ port: 5302, fetch(req) {
const videoThumbs = new Map(), videoInfo = new Map(), tappedClips = new Set();
const feedMedia = () => null, rememberVideo = () => {}, probeVideo = async () => {}, videoHeavy = () => false, heavyLabel = () => '';
const APP_BASE = 'https://v3.coinos.io';
+ const ui = {}; // (not the feed: which page is showing decides the full-screen button)
${dom}
${video}
const url = '/clip.webm';
diff --git a/tools/youtube-tap-test.js b/tools/youtube-tap-test.js
new file mode 100644
index 0000000..271277f
--- /dev/null
+++ b/tools/youtube-tap-test.js
@@ -0,0 +1,110 @@
+// A YouTube clip in a post takes one tap, like any clip: on the picture —
+// the still, or the player already going (autoplayed, muted) — it plays with
+// sound, full screen. The player's own taps never reach the page, so a layer
+// over the picture takes them; YouTube's control bar along the bottom is
+// left to YouTube, and full screen the layer steps aside.
+// Run: bun tools/youtube-tap-test.js
+import puppeteer from './puppeteer.js';
+import { cacheKeyFor } from '../src/wallet.js';
+import { generateSecretKey, getPublicKey, finalizeEvent } from 'nostr-tools/pure';
+import { buildHtml } from '../build.js';
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+let ok = true;
+const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; };
+const png = Bun.spawnSync(['ffmpeg', '-loglevel', 'error', '-f', 'lavfi', '-i', 'testsrc=size=480x360', '-frames:v', '1', '-f', 'image2', '-c:v', 'png', 'pipe:1']).stdout;
+
+const SK = generateSecretKey(), AUTHOR = getPublicKey(SK);
+const now = Math.floor(Date.now() / 1000);
+const POSTS = [
+ finalizeEvent({ kind: 1, created_at: now - 100, tags: [], content: 'watch this https://www.youtube.com/watch?v=dQw4w9WgXcQ' }, SK),
+ ...Array.from({ length: 4 }, (_, i) => finalizeEvent({ kind: 1, created_at: now - 200 - i * 60, tags: [], content: 'filler ' + i + ' ' + 'lorem ipsum dolor sit amet. '.repeat(5) }, SK)),
+];
+const html = await buildHtml({ minify: true, pwa: false });
+const server = Bun.serve({ port: 0, fetch: (req) => {
+ const path = new URL(req.url).pathname;
+ if (path.startsWith('/punks') || path === '/verify-worker.js') return new Response(Bun.file('dist' + path));
+ return new Response(html, { headers: { 'content-type': 'text/html' } });
+} });
+// YouTube, stood in for: the player page notes every command it is sent
+const PLAYER = '<!doctype html><html><body style="margin:0;background:#222;height:100vh"><script>window.__cmds=[];addEventListener("message",(e)=>{try{const m=JSON.parse(e.data);if(m.event==="command")window.__cmds.push(m.func)}catch{}});</script></body></html>';
+
+const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] });
+async function run(saveData) {
+ console.log('\n[' + (saveData ? 'Data Saver: the still first' : 'autoplay: the player already going, muted') + ']');
+ const ctx = await browser.createBrowserContext();
+ const page = await ctx.newPage();
+ await page.setRequestInterception(true);
+ page.on('request', (r) => {
+ const u = r.url();
+ if (u.startsWith('https://www.youtube-nocookie.com/embed/')) return r.respond({ status: 200, contentType: 'text/html', body: PLAYER });
+ if (u.startsWith('https://i.ytimg.com/')) return r.respond({ status: 200, contentType: 'image/png', body: png });
+ return r.continue();
+ });
+ await page.evaluateOnNewDocument((sd) => {
+ if (sd) Object.defineProperty(navigator, 'connection', { configurable: true, get: () => ({ saveData: true, effectiveType: '4g', addEventListener() {}, removeEventListener() {} }) });
+ const Real = window.WebSocket;
+ window.WebSocket = function (...a) { const ws = new Real(...a); const send = ws.send.bind(ws); ws.send = (d) => { try { const m = JSON.parse(d); if (m[0] === 'REQ') { setTimeout(() => ws.dispatchEvent(new MessageEvent('message', { data: JSON.stringify(['EOSE', m[1]]) })), 0); return; } if (m[0] === 'EVENT') return; } catch {} return send(d); }; return ws; };
+ window.WebSocket.prototype = Real.prototype; Object.assign(window.WebSocket, Real);
+ }, saveData);
+ const errs = [];
+ page.on('pageerror', (e) => errs.push(String(e)));
+ const click = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t);
+ const waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await page.evaluate(() => document.body.innerText)).toLowerCase().includes(x)) return true; await sleep(250); } return false; };
+ const waitFor = async (fn, arg, ms = 10000) => { for (let i = 0; i < ms / 100; i++) { if (await page.evaluate(fn, arg)) return true; await sleep(100); } return false; };
+ const box = () => page.evaluate(() => { const b = document.querySelector('.notes-feed .yt-embed').getBoundingClientRect(); return { x: b.x, y: b.y, w: b.width, h: b.height }; });
+ const st = () => page.evaluate(() => { const b = document.querySelector('.yt-embed'); const f = b && b.querySelector('iframe'); const sh = b && b.querySelector('.yt-shield'); return { fs: !!b && document.fullscreenElement === b, iframe: !!f, muted: !!f && /mute=1/.test(f.src), shield: !!sh && getComputedStyle(sh).display !== 'none', thread: !!document.querySelector('.thread-card') }; });
+ const cmds = async () => { const f = page.frames().find((x) => x.url().startsWith('https://www.youtube-nocookie.com/')); return f ? f.evaluate(() => window.__cmds.slice()) : null; };
+ try {
+ await page.setViewport({ width: 390, height: 844 });
+ await page.goto(server.url.href, { waitUntil: 'domcontentloaded' });
+ await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest'));
+ await page.reload({ waitUntil: 'domcontentloaded' }); await sleep(400);
+ await click('create a new wallet'); await sleep(600);
+ await page.waitForSelector('.words .w .t');
+ const mn = (await page.$$eval('.words .w .t', (l) => l.map((e) => e.textContent.trim()))).join(' ');
+ await click('skip verification');
+ await waitText('receive', 20000);
+ const base = cacheKeyFor(mn + '\n');
+ await page.evaluate(([k, pk, ns]) => {
+ localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', pk]], c: '', at: Math.floor(Date.now() / 1000) }));
+ localStorage.setItem(k + ':feedNotes', JSON.stringify(ns));
+ localStorage.setItem(k + ':profiles', JSON.stringify({ [pk]: { name: 'Tuber', t: Date.now() } }));
+ localStorage.setItem('btc-wallet-feed:' + k, 'following');
+ }, [base, AUTHOR, POSTS]);
+ await page.reload({ waitUntil: 'domcontentloaded' });
+ await waitText('receive', 20000);
+ await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]').click());
+ await page.waitForSelector('.notes-feed .yt-embed', { timeout: 20000 });
+ await page.evaluate(() => document.querySelector('.notes-feed .yt-embed').scrollIntoView({ block: 'center' }));
+ await sleep(1500);
+ let s = await st();
+ if (!saveData) {
+ check('in view, the player loads by itself, muted', s.iframe && s.muted, JSON.stringify(s));
+ check('…with a layer over its picture', s.shield);
+ await waitFor(() => !!document.querySelector('.yt-embed iframe'), null, 3000);
+ await sleep(500);
+ // YouTube's control bar along the bottom is YouTube's
+ let b = await box();
+ await page.mouse.click(b.x + b.w * 0.3, b.y + b.h - 20); await sleep(500);
+ check('a tap on YouTube\'s control bar stays YouTube\'s', !(await st()).fs && !(await st()).thread, JSON.stringify(await st()));
+ } else {
+ check('with Data Saver, the still and a play button', !s.iframe && await page.evaluate(() => !!document.querySelector('.yt-embed .yt-play')), JSON.stringify(s));
+ }
+ const b = await box();
+ await page.mouse.click(b.x + b.w * 0.3, b.y + b.h * 0.35);
+ check('one tap on the picture: full screen', await waitFor(() => document.fullscreenElement === document.querySelector('.yt-embed'), null, 3000), JSON.stringify(await st()));
+ s = await st();
+ check('…the player there', s.iframe);
+ check('…with sound', saveData ? !s.muted : (await waitFor(() => true, null, 300)) && (await cmds())?.includes('unMute'), saveData ? JSON.stringify(s) : JSON.stringify(await cmds()));
+ if (!saveData) check('…playing', (await cmds())?.includes('playVideo'));
+ check('…not the thread', !s.thread);
+ check('full screen, the layer steps aside (YouTube\'s controls are all there)', !s.shield, JSON.stringify(s));
+ await page.evaluate(() => document.exitFullscreen()); await sleep(500);
+ s = await st();
+ check('out of full screen, the layer is back', s.shield && !s.fs, JSON.stringify(s));
+ check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | '));
+ } finally { await ctx.close(); }
+}
+try { await run(false); await run(true); } finally { await browser.close(); server.stop(true); }
+console.log(ok ? '\n✅ a YouTube clip: one tap, full screen, with sound' : '\n❌ failed');
+process.exit(ok ? 0 : 1);