Apps
Userscript#
The same job as the extension, for people who would rather not install one. It answers the same messages the site sends, so the site cannot tell the difference.
Pick one or the other. Running the extension and the userscript together means two things answering the same message.
Install#
Install a userscript manager — Violentmonkey or Tampermonkey.
Open the script and confirm your manager's install prompt.
Open setup — or Settings → Connections — and run through it once.
Your manager handles updates from here — the script points at its own source, so you get new versions the same way you get them for any other script.
Compared to the extension#
| Feature | Extension | Userscript |
|---|---|---|
| Making source requests | yes | yes |
| Header rewriting for playback | yes | yes |
| Per-domain permission prompt | yes | granted by the manager |
| Cookies for hosts that need them | yes | via the manager |
The one real gap is header rewriting on requests the browser itself makes.
The extension can ask the browser to do it; a userscript has no equivalent, so
it patches fetch and XMLHttpRequest instead. That covers a player fetching
a playlist and its segments, which is the case that matters in practice.
Media loaded directly by a <video src> is only routed through the script when
it is small — large files are left alone rather than pulled into memory.
Safari and Orion are not supported: WebKit does not give userscript managers or extensions the required network manipulation APIs. Use the desktop app or your own proxy there.
Configuration#
Two constants at the top of the file, if you are editing your own copy:
| Constant | Default | What it does |
|---|---|---|
DEBUG | false | Trace every decision to the console. Off because this runs on every page you visit. |
MAX_BUFFERED_BYTES | 32 MiB | Ceiling for buffering a media response. Above it, the original URL is used untouched. |
Why does it run on every page?#
Because the script has to be able to make a request to a source's domain, and a userscript can only do that from a page it is already running on. It reads nothing and changes nothing on pages other than P-Stream's own — the code is short enough to check before you install it.
If that trade is not one you want to make, the extension asks for the same access but scoped by the browser instead, and the desktop app needs neither.
It's installed but the site doesn't see it#
Reload the P-Stream tab. The site only looks for the script on load.
Check your manager's dashboard shows the script as enabled, and that the manager itself is enabled for this site.
Make sure the extension isn't also installed. If both answer, the result is unpredictable — remove one.