This commit is contained in:
Pachira 2020-10-30 20:29:27 +00:00
parent 5d4b3fe298
commit 2059682fb5

View file

@ -27,28 +27,28 @@ mpv %URL:~0,1%%URL:~5,255%
**/
window.addEventListener('click', function(ev) {
var target = ev.target;
while(!(target instanceof HTMLAnchorElement)) {
var target = ev.target;
while(!(target instanceof HTMLAnchorElement)) {
target = target.parentNode;
if(!target)
if(!target)
return;
}
if(!target.href)
if(!target.href)
return;
var url = new URL(target.href);
if(url.protocol === 'mpv:')
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;
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);