# StreamingCommunityZ TV

TizenBrew **mods** module: turns `streamingcommunityz.tech` into a TV interface with
D-pad remote navigation and player popup blocking. Runs on Samsung Tizen TVs via TizenBrew.

## What it does

- **D-pad navigation** — arrows move a focus highlight between cards / buttons, OK clicks, BACK goes back.
- **Spatial focus** — geometric nearest-element-in-direction (no site cooperation needed).
- **Popup blocking** — kills `window.open`, blocks `target="_blank"` + cross-host ad links,
  sweeps overlay/ad nodes, bounces forced redirects.
- **Player popup fix** — the popunder fires on the first click over the player: a transparent
  overlay / anchor stacked above the `vixcloud` iframe swallows that click and opens the ad.
  We locate the player iframe and remove that click-catcher (`CONFIG.blockPlayerOverlays`).
  We do **not** sandbox the player: `vixcloud` has anti-sandbox security and refuses to play
  inside a sandboxed iframe (`CONFIG.sandboxPlayer` is `false` and should stay off).
- **Recovery mode** — if init fails repeatedly, removes all modifications so the site stays usable.

## Site structure (analyzed live)

- Vue + scoped styles. Root `#app`.
- Cards: `.slider-item > a[href*="/it/titles/{id}-{slug}"]`, cover `img.cover-image`.
- Play: `a.play[href="/it/watch/{id}"]` ("Riproduci"), grid buttons `.play-btn` / `.play-wrap`.
- Player chain: `/it/watch/{id}` → same-origin iframe `/it/iframe/{id}` → **cross-origin** `vixcloud.co/embed` → `<video>`.
- Because the `<video>` lives in a cross-origin iframe, parent-page JS cannot control playback
  or read inside it. Remote media keys are therefore passed through to the focused iframe
  (native player handles them).

## Tizen / Chromium 47 constraint

The Tizen TV browser is **Chromium 47, ES5 only**. `index.js` is plain ES5 on purpose:
no arrow functions, no `let`/`const`, no template strings, no `export`. Keep it that way.

## Install / run on TV

Requires TizenBrew already installed on the TV.

1. Publish this package to npm:
   ```bash
   npm login
   npm publish --access public
   ```
2. On the TV: open **TizenBrew** → MarketPlace / Add module → enter
   `tizenbrew-streamingcommunityz-tv`.
3. TizenBrew opens `websiteURL` and injects `index.js`.
4. Test the remote: arrows navigate, OK clicks, BACK returns.

### Iterate fast (without publishing each time)

Test the logic in desktop Chrome first — see `test/desktop-test.md`. Then bump + publish:
```bash
npm version patch && npm publish
```

## Config

Edit the `CONFIG` block at the top of `index.js`:

| Key | Purpose |
|-----|---------|
| `blockPlayerOverlays` | `true` = remove the transparent click-catcher over the player that opens the popunder on play. Keeps vix working. |
| `sandboxPlayer` | Keep `false`. vixcloud refuses to play sandboxed. Only flip on if you accept losing playback for a hard popup block. |
| `focusColor` / `focusSize` | Focus highlight style. |
| `hideSelectors` | CSS-hidden junk (ads, cookie banners, modals). |
| `extraFocusable` | Non-`<a>`/`<button>` clickable selectors specific to this site. |

## Known limits

- The popunder is blocked by removing the overlay click-catcher above the player. If the ad
  network changes its overlay shape, update `killPlayerOverlays()` (it targets anchors / external
  links / empty overlays stacked over the player center).
- A forced top-redirect to an ad domain is caught by the redirect-bounce (`window.history.back`).
- Media keys (play/pause/seek) can't drive the cross-origin `<video>`; focus the player and use
  its own on-screen controls via the D-pad.
