Files

56 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

# Plex Auto Skip
A small Chrome extension that automatically clicks "Skip Intro" and "Skip Credits" on Plex Web, so you don't have to reach for the mouse every time.
## Features
- Watches the Plex Web player and clicks "Skip Intro" / "Skip Credits" the instant either button appears.
- Works on `app.plex.tv` by default, or point it at your own server address (local IP, custom domain, whatever you use).
- Toggle Skip Intro and Skip Credits independently — both on by default.
- Optional delay (0-30s) before each is clicked, in case a show needs a few extra seconds before the credits skip feels right.
- Settings save instantly and apply live, no reload required for toggle or delay changes.
- The settings popup follows your browser/OS dark mode setting automatically.
## Install
1. Download or clone this repo.
2. Open `chrome://extensions` in Chrome.
3. Turn on **Developer mode** (top right toggle).
4. Click **Load unpacked** and select this project's folder.
5. Click the extension's icon in the toolbar to open its settings.
## Settings
- **Plex URL** — defaults to `app.plex.tv`. Choose "Custom URL" and enter your own server address (e.g. `192.168.1.50:32400/web` or a custom domain) if you watch there instead.
- **Skip Intro** / **Skip Credits** — both on by default. Uncheck either one if you'd rather click it yourself sometimes.
- **Delay before clicking** — a 0-30 second slider under each toggle. Leave at 0 to click the instant the button appears (the original behavior), or add a few seconds if a particular show's Skip Credits button shows up before you're actually ready for it to fire. Each slider is disabled while its skip toggle is off, since a delay for a skip that isn't happening doesn't do anything.
Changing the Plex URL takes effect on your next page load — refresh your Plex tab after saving a new one. Toggle and delay changes apply immediately, no refresh needed.
Clicking **Save** closes the popup automatically shortly after confirming the save, so you don't have to click elsewhere to dismiss it. If something's wrong with what you entered (like a blank or invalid custom URL), the popup shows an error and stays open instead.
## How it works
The extension's content script runs on every page but only activates once the page's hostname matches your configured Plex URL. From there it uses a `MutationObserver` to watch the page for any `<button>` or `[role="button"]` element whose visible text contains "skip intro" or "skip credit" (case-insensitive, so it still matches if Plex appends a countdown like "Skip Intro 0:05"). When a match appears and is actually visible, it schedules a click — immediately if its delay is 0, or after the configured delay otherwise. Right before a delayed click actually fires, it re-checks that the button is still present, visible, still says "Skip Intro"/"Skip Credits", and that its toggle is still on — so turning a toggle off, or Plex removing the button, cancels a pending click instead of firing it late. A short cooldown per element stops a single button from being double-clicked in one burst, but still allows a later click if Plex reuses the same button element for the next episode.
Settings (your Plex URL and the two toggles) are stored with `chrome.storage.sync`, so they follow you across machines if you're signed into Chrome.
## Testing
This project has an automated test suite that simulates the Plex Web DOM with [jsdom](https://github.com/jsdom/jsdom) and exercises the real extension code — no browser or live Plex server required.
```
npm install
npm test
```
The suite covers: clicking Skip Intro/Skip Credits, ignoring non-Plex pages, respecting the on/off toggles, matching a custom server URL, reacting to buttons added dynamically after page load, ignoring unrelated buttons, handling countdown suffixes in the button text, not clicking hidden buttons, correctly re-clicking a reused button after its cooldown, delayed clicks (including cancellation when a toggle turns off or the button disappears mid-delay), and the settings popup's save/validation/load behavior for the URL, the delay sliders, and auto-close on save.
## Troubleshooting
If skipping stops working after a Plex Web update, it's most likely because Plex changed the button markup. Open DevTools on the player page, inspect the Skip Intro/Skip Credits button, and check whether it's still a `<button>` or `[role="button"]` element with "Skip Intro"/"Skip Credits" somewhere in its visible text. Open an issue (or a PR) with what you find.
## License
MIT — see [LICENSE](LICENSE).