Skip to content

Instantly share code, notes, and snippets.

@viliampucik
Last active October 17, 2025 22:06
Show Gist options
  • Select an option

  • Save viliampucik/94cab9cb76246eac7b1dc64cd247bd81 to your computer and use it in GitHub Desktop.

Select an option

Save viliampucik/94cab9cb76246eac7b1dc64cd247bd81 to your computer and use it in GitHub Desktop.
MPV YouTube
ytdl-format=bestvideo[ext=mp4][height<=1080]+bestaudio/best[ext=mp4]/best
// ==UserScript==
// @name MPV YouTube
// @namespace vip
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
var p = document.getElementById("player");
if (p) {
p.addEventListener("click", function(e){
e.stopPropagation();
var list = document.getElementsByClassName("html5-video-player");
if (list.length) {
var rect = list[0].getBoundingClientRect();
var geometry = `${rect.width}x${rect.height}` +
`+${Math.ceil(rect.left) + window.screenX}` +
`+${rect.top + window.screenY + window.outerHeight - window.innerHeight + 10}`;
console.log(`ytvideo://${document.URL}|--geometry=${geometry}`);
window.open(`ytvideo://${document.URL}|--geometry=${geometry}`).close();
}
}, true);
}
[Desktop Entry]
Version=1.0
Name=MPV YouTube
Exec=/usr/bin/ytvideo.sh %U
Terminal=false
Type=Application
MimeType=x-scheme-handler/ytvideo
#!/bin/sh
IFS=\| read url options <<< "${1//%20/ }"
/usr/bin/mpv ${options} "${url#ytvideo://}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment