A browser userscript that will allow you to open videos in external player mpv by simply clicking on a thumbnail without loading bloated video page with web player.
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.
- 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
- Any modern web browser that supports extensions
- mpv media player
- youtube-dl
- Userscript manager, such as Violentmonkey, Greasemonkey or Tampermonkey
- Clone this repository
- Do one of the following:
- Install script from Greasyfork or OpenUserJS
- Create a script in your browser userscript manager and paste contents of userscript.js from this repository
- Make sure the userscript is enabled
- Install mpv URL handler using the commands below
$ chmod +x install.sh
$ ./install.sh
- Ensure you have mpv and youtube-dl extracted in the same folder.
- Download Windows archive for your architecture from mpv-url-handler repository
- Unzip the downloaded archive to mpv installation folder
- Download handler-install.bat script from mpv-handler by akiirui repository.
- Copy handler-install.bat into mpv folder
- Run handler-install.bat to register protocol handler (as Administrator)
If it does not work, add MPV folder to your PATH environment variable. (requires administrator rights)
set PATH=%PATH%;C:\your\path\to\mpv\folder\here\
- 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)
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 after you performed Search.
Tested and confirmed working in the following setups:
- GNU/Linux with Xorg, Mozilla Firefox, Violentmonkey
- Windows 32-bit, Chrome, Tampermonkey
- Windows 64-bit, Firefox, Violentmonkey
For better experience you may want to set max quality in mpv config. For example: you want vidoes to be viewable in not higher than 1080p.
To accomplish that, 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
ytdl-format=bestvideo[height<=1080]+bestaudio