# tubev — Site Migration Playbook **Призначення:** robust план для міграції / refactor наступного site (player, banners, sidebar responsive, etc.). Не лінійний — **discovery-driven** з conditional branches. Кожен пункт може бути SKIP якщо feature відсутня. > Спирається на досвід з 8148 (PlayerJS pilot), 8161 (full migration + R7 responsive sidebar), 8081 (videojs10 + bannersBlocks reference). Доповнення — у [ADS.md § Migration checklist](ADS.md#migration-checklist--legacy-videojs4--modern-playerjs--ad-bundle). --- ## Phase 1 — Discovery (ОБОВ'ЯЗКОВО спершу) Перед будь-якими правками — Claude **запитує юзера** + інспектує наявний site, фіксує scope. Без цього — risk hidden assumptions. ### A) Scope decisions (запитати юзера) | # | Питання | Why it matters | |---|---------|---------------| | A1 | **Чи мігруємо player?** (videojs4 → PlayerJS / videojs10 / залишаємо?) | Якщо ні — skip Phase 3 player. | | A2 | **Чи замінюємо ad spot IDs?** (rotation / new account) — якщо так, дай mapping таблицю. | Якщо ні — skip banner spot rewrite. | | A3 | **Чи треба responsive sidebar→grid swap (R7-style)?** | Tільки якщо site має sidebar з ads AND junior-grid (related/recommended thumbs). | | A4 | **Чи зробити уніфікацію критичних inline + index.css?** | За замовчуванням так — запобігає FOUC. | | A5 | **Spec for site** — щось унікальне (custom player, ASG-bypass, GDPR overlay, etc.)? | Невідомі вимоги дізнаємось ранo, не пізно. | ### B) Site inspection (Claude робить empirically) | # | Check | Tool / Command | |---|-------|----------------| | B1 | URL pattern для video page | grep `id_index` references у layout, парсинг `mysettings.location_css == "id"` block | | B2 | Player generation у DOM | `curl t1./` → grep `videojs\|PlayerJS\|pjs_container` | | B3 | Native banners серед thumbs (1thumb_a-f чи інший module чи нема) | `grep -rn 'native_allpg_1thumb\|render.*banners' views/modules/related_video.etlua views/modules/recommended_video.etlua` | | B4 | Sidebar layout (vi-side-col? інший?) | `grep -n 'embed_sidebar\|vi-side-col\|sidebar_adspy' views/id_index.etlua` | | B5 | Cols-change button (для bannersBlocks observer scope) | `grep -rn 'changeNumberCols\|data-changecolumns' views/` | | B6 | CSS layers — `index.css` + критичні `views/css/css_.etlua` | `ls views/css/css_*.etlua` | | B7 | Shared lib references — `views/static/js/lib/` git submodule? | `cd views/static/js/lib && git remote -v` | | B8 | Cooldown regex у `layout.etlua` (popunder spot ID hardcoded) | `grep 'asgsl\|_popRr' layout.etlua` | | B9 | `c` counter call безпеки (`if(typeof c==="function")`) | grep `tb.start_events_v2` у `id_index.etlua` | | B10 | `lazyLoadFunc` defined inline | `grep -c 'function lazyLoadFunc' layout.etlua views/static/js/main.min.js` | **Output Discovery phase:** короткий summary — "Site X: player Y, banners Z (mapping pending), sidebar W, cols-button A/N, etc." → юзер confirms scope перед Phase 2. --- ## Phase 2 — Conditional Task Branches Кожна гілка SKIP-нулагається якщо Discovery показав feature відсутньою. **Кожна = окремий atomic commit.** ### Branch P (Player migration) — якщо A1=yes → повний 30+ checkpoint список у [ADS.md § Migration checklist](ADS.md#migration-checklist--legacy-videojs4--modern-playerjs--ad-bundle). - Inline lazysizes wrapper якщо main.min.js його не містить (R3). - `if(typeof c==="function")` guard (counter race fix). - foreign 8148 classes (`vdo-blk-*`) → site-native (`vi-limiter` etc.) (R5). - Playwright probe → pageerrors empty. ### Branch S (Spot ID rotation) — якщо A2=yes - Replace IDs у `views/static/js/ad-config.js` (popunder.spot, vast.spot). - Replace `(?:^|\|)=` regex у `layout.etlua` (must sync з ad-config!). - Replace IDs у `views/modules/banners/*adspy*.etlua` (footer/header/middle/sidebar/native). - 1thumb_a..f spots якщо site має those modules. - Per-site inventory таблицю — додати у [ADS.md § Per-site spot inventory](ADS.md#per-site-spot-inventory). - Build bundle → cache-bust md5. - ad-test → 6/6 PASS на новий popunder/vast spots. ### Branch R7 (Responsive sidebar→grid) — якщо A3=yes Передумови: site має sidebar (`.vi-side-col` чи аналог) з ad slots AND grid (`#related_video_block` чи similar) з thumbs. 1. **Уніфікувати DOM IDs** sidebar slots (mobile + desktop templates обидва використовують ті самі ID — `sdd_a`/`sdd_b`). 2. **Move banner-load logic** з template `