mpv things

This commit is contained in:
Pachira 2020-10-03 16:22:14 +00:00
parent 68a227e117
commit aa29a55da8
2 changed files with 60 additions and 0 deletions

6
public/mpv.php Normal file
View file

@ -0,0 +1,6 @@
<!doctype html>
<a id="mpv" href="mpv:<?=filter_input(INPUT_GET, "url", FILTER_SANITIZE_URL);?>">Open in MPV</a>
<script>
document.getElementById('mpv').click();
setTimeout(function() { window.close() }, 1);
</script>

View file

@ -0,0 +1,54 @@
// ==UserScript==
// @name mpv friend
// @version 1
// @grant none
// ==/UserScript==
/** mpvfriend.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\mpv]
@="URL:mpv"
"URL Protocol"=""
"DefaultIcon"="\"C:\\Users\\Julian\\Software\\mpv\\mpv.exe\",1"
[HKEY_CLASSES_ROOT\mpv\shell]
[HKEY_CLASSES_ROOT\mpv\shell\open]
[HKEY_CLASSES_ROOT\mpv\shell\open\command]
@="\"C:\\Users\\Julian\\Software\\mpv\\open.bat\" \"%1\""
**/
/** open.bat
@echo off
set URL=%1
mpv %URL:~0,1%%URL:~5,255%
**/
window.addEventListener('click', function(ev) {
var target = ev.target;
while(!(target instanceof HTMLAnchorElement)) {
target = target.parentNode;
if(!target)
return;
}
if(!target.href)
return;
var url = new URL(target.href);
if(url.protocol === 'mpv:')
return;
if((url.origin === 'https://www.youtube.com' && url.pathname === '/watch')) {
ev.preventDefault();
ev.stopPropagation();
var open = document.createElement('a');
open.href = 'https://flash.moe/mpv.php?url=' + encodeURIComponent(url.href);
open.target = '_blank';
document.body.appendChild(open);
open.click();
document.body.removeChild(open);
return false;
}
}, true);