A lightweight userscript that adds a native A/B loop panel directly into the YouTube player β no extension, no bloat. Works with ScriptCat, Tampermonkey, and any compatible userscript manager.
- A β B loop β set two timestamps and loop between them indefinitely
- Full video loop β restart the entire video automatically on end
- Mini timeline β draggable thumbs for A, B and the playhead, with a highlighted range overlay
- Keyboard shortcuts β press
AorBto set points at the current time - Auto-update banner β the panel shows a notification when a newer version is available on GitHub
- Native look β glass-morphism panel that matches YouTube's own UI style
- Zero performance waste β RAF-based render loop with per-frame value caching; only writes to the DOM when something actually changes
| Panel β A/B mode | Panel β Full video mode |
|---|---|
![]() |
![]() |
A userscript manager installed in your browser. Recommended options:
| Manager | Browsers | Link |
|---|---|---|
| ScriptCat β | Chrome, Firefox, Edge | scriptcat.org |
| Tampermonkey | Chrome, Firefox, Edge, Safari | tampermonkey.net |
| Violentmonkey | Chrome, Firefox, Edge | violentmonkey.github.io |
Click the link below β your userscript manager will open an install prompt automatically:
- Open ScriptCat (or Tampermonkey) β Create a new script
- Paste the contents of
youtube-loop.js - Save (
Ctrl+S)
| Action | How |
|---|---|
| Open the panel | Click the β button in YouTube's right toolbar |
| Set point A | Click Set on the A card, or press A |
| Set point B | Click Set on the B card, or press B |
| Clear a point | Click β next to the point |
| Enable loop | Toggle the Loop off / Loop on pill switch |
| Switch mode | Click Full video or A β B |
| Reset everything | Click Reset |
| Seek | Click anywhere on the mini-timeline, or drag any thumb |
Tip: You can set A and B while the video is playing β the loop activates immediately.
ScriptCat and Tampermonkey both check for updates automatically (once per day by default) using the @updateURL and @downloadURL directives in the script header.
When a new version is published on GitHub, a yellow "Update available" banner also appears at the bottom of the panel with a direct Install link.
To bump the version yourself, update both:
@versionin the userscript headerCURRENT_VERSIONconstant in the code
tryInject() β inject()
βββ mountUI() β injects CSS + builds DOM
βββ setupModeSelector()
βββ setupPanelToggle()
βββ setupLoopToggle()
βββ setupPointButtons()
βββ setupTimeline()
βββ setupKeyboard()
βββ startRenderLoop() β RAF loop, enforces A/B boundary
βββ checkForUpdate() β async GitHub version fetch
Navigation between YouTube videos is handled via a MutationObserver on <title> (lightweight β fires only on SPA navigations, not on every DOM change). Each page gets a fresh isolated session object β no stale state between videos.
# Clone
git clone https://github.com/Black0S/Youtube-Loop-UserScript-.git
# Edit
# youtube-loop.js is a single self-contained file β no build step required.
# Test
# Install locally via ScriptCat or Tampermonkey, open any YouTube video.When releasing a new version:
- Bump
@versionin the header (e.g.1.0.0β1.1.0) - Bump
CURRENT_VERSIONconstant to match - Push to
mainβ ScriptCat, Tampermonkey, and the in-panel banner will all pick it up automatically
MIT Β© Black0S


