gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmaind2e6d26bMerge branch 'records-park55' into mainTrackermain/tests/tmdbfix-chrome.mjs

4.0 KB

  1. // tests/tmdbfix-chrome.mjs — tracker#36 (mission T36): look at titles of a COPY in the creator's Chrome on lisbeth (:9223): ONE own plain
  2. // tab (Target.createTarget WITHOUT a browser context), closed in finally, browser disconnected (never closed), one own cookie (deleted
  3. // again), at 390×844 / 800×1280 / 1280×800 / 1280×900, a screenshot of every page and size plus the visible text of the page head.
  4. // BASE=http://localhost:8761 SID=<session id of the copy> OUT=/abs/shots CDP=http://127.0.0.1:9223 PATHS='/shows/The-Daily-Show,/movies/X' node tests/tmdbfix-chrome.mjs
  5. // Run it under `timeout 600 flock /media/STORAGE/claude-scratch/atlas/lisbeth.lock …` (WORKER-RULES). Prints one JSON line per page and size.
  6. import fs from 'node:fs';
  7. const BASE = process.env.BASE, SID = process.env.SID, OUT = process.env.OUT, CDP = process.env.CDP || 'http://127.0.0.1:9223';
  8. const PATHS = (process.env.PATHS || '').split(',').filter(Boolean);
  9. if (!BASE || !SID || !OUT || !PATHS.length) { console.log('set BASE, SID, OUT, PATHS'); process.exit(2); }
  10. fs.mkdirSync(OUT, { recursive: true });
  11. const SIZES = [[390, 844, true, 2], [800, 1280, false, 1], [1280, 800, false, 1], [1280, 900, false, 1]];
  12. const ver = await (await fetch(CDP + '/json/version')).json();
  13. const ws = new WebSocket(ver.webSocketDebuggerUrl.replace(/^ws:\/\/[^/]+/, CDP.replace('http', 'ws')));
  14. await new Promise((res, rej) => { ws.onopen = res; ws.onerror = rej; });
  15. let nextId = 1; const waiting = new Map(); const events = [];
  16. ws.onmessage = (m) => { const j = JSON.parse(m.data); if (j.id && waiting.has(j.id)) { const w = waiting.get(j.id); waiting.delete(j.id); j.error ? w.rej(new Error(j.error.message)) : w.res(j.result); } else if (j.method) events.push(j); };
  17. const send = (method, params = {}, sessionId) => new Promise((res, rej) => { const id = nextId++; waiting.set(id, { res, rej }); ws.send(JSON.stringify({ id, method, params, ...(sessionId ? { sessionId } : {}) })); });
  18. const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  19. let targetId = null, sid = null;
  20. const cookieUrl = BASE;
  21. try {
  22. targetId = (await send('Target.createTarget', { url: 'about:blank' })).targetId;
  23. sid = (await send('Target.attachToTarget', { targetId, flatten: true })).sessionId;
  24. const S = (m, p) => send(m, p, sid);
  25. await S('Page.enable'); await S('Network.enable'); await S('Runtime.enable');
  26. await S('Network.setCookie', { name: 'trackersid', value: SID, url: cookieUrl });
  27. const ev = async (expr) => (await S('Runtime.evaluate', { expression: expr, returnByValue: true })).result.value;
  28. for (const [w, h, mobile, dsf] of SIZES) {
  29. await S('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: dsf, mobile });
  30. for (const p of PATHS) {
  31. await S('Page.navigate', { url: BASE + p });
  32. for (let i = 0; i < 100; i++) { await sleep(300); if (await ev("document.readyState === 'complete' && !!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1")) break; }
  33. await sleep(1500);
  34. const info = await ev(`JSON.stringify({ url: location.pathname, title: document.title, h1: (document.querySelector('h1') || {}).textContent || null, scrollW: document.documentElement.scrollWidth, innerW: innerWidth,
  35. head: document.body.innerText.replace(/\\s+/g, ' ').slice(0, 260), checks: document.querySelectorAll('button.checkicon').length, imgs: Array.from(document.images).filter(i => i.complete && i.naturalWidth > 0).length + '/' + document.images.length })`);
  36. const shot = (await S('Page.captureScreenshot', { format: 'png' })).data;
  37. const name = `${p.replace(/[^A-Za-z0-9]+/g, '_')}-${w}x${h}.png`;
  38. fs.writeFileSync(`${OUT}/${name}`, Buffer.from(shot, 'base64'));
  39. console.log(JSON.stringify({ size: `${w}x${h}`, shot: name, ...JSON.parse(info) }));
  40. }
  41. }
  42. await S('Emulation.clearDeviceMetricsOverride');
  43. await S('Network.deleteCookies', { name: 'trackersid', url: cookieUrl });
  44. } finally {
  45. if (targetId) { try { await send('Target.closeTarget', { targetId }); } catch (e) { console.log('close failed: ' + e.message); } }
  46. ws.close();
  47. }

Branches

Latest commits

  • d2e6d26bMerge branch 'records-park55' into mainTracker
  • f567f025|||PR records: park #55, no Claude workers ruleTracker
  • c21aff6bMerge branch 'records-hm55c' into mainTracker
  • 9ba258d3|||PR records: HM55b resultTracker
  • 64f2d300Merge branch 'records-hm55b2' into mainTracker
  • ae3b80dc|||PR records: HM55b briefTracker
  • 7ef3cb3bMerge branch 'records-st55' into mainTracker
  • fec2e080|||PR records: STATUS HM55Tracker
  • 8e174918Merge branch 'records-hm55b' into mainTracker
  • b1ecee57|||PR records: HM55 stateTracker
  • 28eab08cMerge branch 'records-hm55' into mainTracker
  • d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
  • 3059f86cMerge branch 'records-design-rule' into mainTracker
  • 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
  • d1390692Merge branch 'records-dp75b' into mainTracker
  • a4d1a7d2|||PR records: later steps checked, branch auditTracker
  • e070e16fMerge branch 'records-dp75' into mainTracker
  • 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
  • bfc4ea4dMerge branch 'ap62' into mainTracker
  • 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker