Ad-Free YouTube With a Custom Player
Source: Dev.to

As enshittification marches on—more ads, more dark patterns, UI designed to serve the platform instead of the user—I’ve been writing userscripts to take back control of my browser. The web is full of intrusive UI: search results that hide answers behind AI summaries, cookie banners that trick you into opting in, and click‑bait overlays.
YouTube is one of the worst offenders: pre‑roll ads, mid‑roll interruptions, and recommended‑video overlays that hijack the screen. Fortunately, YouTube’s own embed domain youtube-nocookie.com serves no ads. By intercepting youtube.com/watch?v=VIDEO_ID links and routing them through a third‑party pass‑through (yout-ube.com), the request is rewritten to a nocookie embed while preserving the correct HTTP Referer. This avoids the “Error 153” that kills playback when navigating directly to a nocookie URL.
A second script runs on the nocookie domain to enhance the player, giving you the full video with zero ads.

What I Built
Speed hold
Hold the mouse button over the video to speed it up:
- Upper half → 2× speed
- Lower half → 3× speed
Release to snap back to 1×. No UI elements, just muscle memory.
Double‑click fullscreen
YouTube’s overlay swallows the native dblclick event, so the script tracks clicks manually. Two clicks within 300 ms over the video area toggle fullscreen.
Comments panel
A collapsible panel at the bottom of the player pulls comments via the YouTube Data API v3. Features include:
- Top or New sort
- Like counts, timestamps
- Like/dislike ratio bar
UI Cleanup
The nocookie player still renders unwanted elements (e.g., “watch on YouTube” button, fullscreen recommendations overlay, loop icon). All of these are removed with CSS:
player-fullscreen-action-menu,
.ytp-pause-overlay-container,
.watch-on-youtube-button-wrapper,
.ytFullscreenVideoRecommendationsHost {
display: none !important;
}Volume, closed captions, and settings buttons are relocated to a custom bottom bar for a tidier interface.
Set It Up Yourself
- Video walkthrough:
- Full written instructions, both scripts, and API‑key setup: