# tubev — Ads Integration Реклама через **adspyglass.com**. Основне джерело монетизації — балансуємо CTR vs UX/PSI. ## Status 🟢 **Working knowledge** — Skeleton наповнюємо. ## ⚙️ Automated regression test — `ad-test` Швидкий smoke перевірити що ad flow не поламано після зміни. ```bash # default — 3 URLs з 8148 (швидкий smoke) ad-test # конкретні URLs ad-test "https://www.xn--3dsq7teoyo9d.com/v/box/123/foo" \ "https://t1.atube.sex/v/box/456/bar" # з screenshots + JSON report ad-test --screenshot --json "https://..." "https://..." ``` **Що перевіряє per URL:** 1. ✓ ad-bundle loaded (`window._adConfig` set, spot IDs читаються) 2. ✓ popunder SDK loads 3. ✓ `/api/users/` повертає `` (не empty no-fill) 4. ✓ mode = "vast" після popunder cooldown 5. ✓ `.asg-container` injects на click `pjs_play_btn` (правильний `data-spot-id`) 6. ✓ console clean (no `[ASGB LOADER]` errors, no `pageerror`) **Exit code:** 0 = всі pass, 1 = ≥1 fail. Можна chain у CI / git hook. **Реалізація:** - Wrapper: `/home/w4/bin/ad-test` - Script: `/home/w4/playwright-tests/ad-regression.mjs` (Playwright + Chromium headless) - Repo copy (versioned): `scripts/ad-regression.mjs` + `scripts/ad-test.sh` **Обмеження headless:** - Real video playback не verifies (autoplay restrictions, VPAID не fully supported у chromium-headless-shell) - Network-level VAST chain validation (через `//` детекцію) cover 95% regressions без візуальної перевірки - Якщо треба видеоплей — `ad-test --full` (full chromium, але VPAID все ще incomplete) - Альтернатива для full visual: запусти у real browser з `?debug=1` + дивись HUD ## Architecture ### Mirrors (зеркала) Реклама вантажиться через **зеркала-домени**, не прямо `adspyglass.com`: - `a5.g--o.info` — ad orchestration (preconnect target у modern setup) - `surstrom.com` — inline ad-spot loader (legacy pattern) - `agego.com` — verifycdn (`verifycdn.agego.com/v1/verify.js`) - `g--o.info` — base domain - (інші додаються на потребу) **Чому зеркала:** anti-block — adblockers баняють відомі ad-домени. Зеркала маскують та ротуються. **Mirror lifecycle:** - Зеркала **періодично баняться** (adblock list updates) - Заміна — **mass-operation через Адміна** (одразу на всі сайти) - Ми не керуємо вибором зеркал — це адмінська функція ### Three architecture patterns coexist (audit 2026-05-02) Site-level audit показав **3 patterns** — не uniform: | Pattern | Sites | Як виглядає | Примітка | |---------|-------|-------------|----------| | **A) Modern bundle** | 1 (тільки 8148) | ``** з cache-bust md5. - [ ] **Inline `lazyLoadFunc` definition** (з `views/static/js/lazysizes.min.js` content) ПІСЛЯ inline lazysizes core block — інакше `timeline-pjs.min.js` кине `ReferenceError: lazyLoadFunc is not defined` (8161 fix 2026-05-04). - [ ] **Body inline scripts** (port 8148 lines 184-434): `_initPjs()`, `_revealPjs()`, `_playAt()`, click handler на `.` capture phase, VAST overlay click forwarder. - [ ] **Guard counter calls:** `tb.start_events_v2(() => { if(typeof c==="function") c(<%-video.video_id%>,0,"click",0); }, ...)` — `c()` defined у async-loaded `counters.v2.min.js`, без guard race-error (`c is not defined`). ### id_index.etlua - [ ] **Replace videojs4 DOM** з PlayerJS structure: `
` + `