nsinister / Click on video thumbnail to play in MPV


Version: 0.1+667d662 updated

Summary: Open videos in external player (mpv) by simply clicking on a thumbnail.


Copyright: 2021, nsinister

License: MIT


This userscript will allow you to open videos in external player mpv by simply clicking on a thumbnail without loading bloated video page with web player.

How it works

It simply replaces video thumbnail hyperlinks on a page, changing their protocol from https:// to mpv:// and coding the original URL as base64. The result string is then passed to mpv:// URI handler as base64 string.


  • Live streams aren't fully supported by mpv + youtube-dl, thus you may want to avoid clicking on live stream thumbnails
  • Cookies are not passed in any way, hence private vidoes (subscriber only) won't play
  • Video quality is automatically chosen by MPV, so you can configure MPV to your liking (see notes below)

Prerequisites in your system

Supported sites

  • YouTube
  • Vimeo

Potentially it works with anything that mpv and its youtube-dl backend supports. But in order to add support for a certain website, one needs to find its DOM selector for site specific video thumbnails and put it into the dictionary inside the userscript


Install this script, then follow instructions below


Handler install script

If you want automatic installation of mpv URL handler, refer to README in project's github repository. There you can download install script.
If you don't want to go to github, continue reading the next section on how to manually install the handler script.

Manual standalone installation:

$ mkdir -p ~/.local/bin/ && touch ~/.local/bin/
$ chmod +x ~/.local/bin/
$ mkdir -p ~/.local/share/applications && touch ~/.local/share/applications/mpv-url-handler.desktop

Edit file ~/.local/bin/ with a text editor, put the following contents

mpv `echo -n ${1%/} | sed 's/mpv:\/\///' | base64 --decode`

Edit file ~/.local/share/applications/mpv-url-handler.desktop

[Desktop Entry]
GenericName=Multimedia player
Comment=Play web media content with mpv

Finally, register mpv URL handler for mpv://

$ echo "Exec=$HOME/.local/bin/ %u" >> ~/.local/share/applications/mpv-url-handler.desktop
$ xdg-mime default mpv-url-handler.desktop x-scheme-handler/mpv


  1. Ensure you have mpv and youtube-dl extracted in the same folder.
  2. Download Windows archive for your architecture from mpv-url-handler repository
  3. Unzip the downloaded archive to mpv installation folder
  4. Download handler-install.bat script from mpv-handler by akiirui repository.
  5. Copy handler-install.bat into mpv folder
  6. Run handler-install.bat to register protocol handler (run as Administrator)

If it does not work, add MPV folder to your PATH environment variable. (run as Administrator)

set PATH=%PATH%;C:\your\path\to\mpv\folder\here\

Known bugs

New video links are not generated after consequent search on YouTube.

When you Search on YouTube consequently, it doesn't reload page, so previous links are preserved as onclick events. Workaround: reload page (Ctrl+R) after you performed Search.


For better experience you may want to set max quality in mpv config.
For example, you want vidoes to be viewable in 1080p, not higher (4K)

Edit file ~/.config/mpv/mpv.conf in GNU/Linux or mpv.conf in your mpv folder, create file if not exists
Add the following line in mpv.conf


Rating: 0