I already Posted this in another Thread, but I'm not sure if it's easily findable there, so I'm posting it here Again.
So I made an Greasemonkey Script which extracts HTML5 Videos and Youtube Video Links, removes the HTML5 Video Element and put's them into the Clipboard where an external Player or Script can pick it up.
Here the Greasemonkey Script:
Code: Select all
// ==UserScript==
// @name Video2Clipboard
// @namespace none
// @description Copies "youtube.com/watch" URL and HTML5 Video Sources to Clipboard and removes the Element, so External Programs can pick them up.
// @include *
// @version 1.0
// @grant GM_setClipboard
// ==/UserScript==
var clipprefix="extplay ";
var regex = /https*:\/\/www.youtube.*\/watch/;
//Check if Youtube
if (regex.test(window.location.href)) {
GM_setClipboard(clipprefix+window.location.href)
return;
}
//Remove and copy HTML5 Videos
//document.addEventListener('DOMContentLoaded',function() {
var elems = document.querySelectorAll("video");
for (var i = 0; i < elems.length; i++) {
elems[i].remove();
GM_setClipboard(clipprefix+elems[i].querySelector("source").getAttribute("src"));
}
//});
//Remove and copy newly created video elements
document.addEventListener("DOMNodeInserted", function(e) {
var elem = e.target;
if (elem.nodeName == "VIDEO") {
elem.remove();
GM_setClipboard(clipprefix+elem.querySelector("source").getAttribute("src"));
}
}, false);
And here an Bash One-liner which detects and passes the Link to the Videoplayer (smplayer in this Case):
Code: Select all
while true; do if [[ -n $( xclip -o | grep '^extplay') ]]; then url=$(xclip -o | awk '{print $2}'); smplayer $url; echo $url | xclip -i; fi; sleep 1; done
1.) an Videoplayer that supports Youtube Video Links (which is the case for smplayer)
2.) and NoScript to stop the Embedded Youtube-Player from Playing.