X-Git-Url: https://jasonwoof.com/gitweb/?p=userscripts.git;a=blobdiff_plain;f=youtube-html5-hider%2Fscript.js;fp=youtube-html5-hider%2Fscript.js;h=444afd1bc23f77d9176b77a12ce1dd6177d681ba;hp=0000000000000000000000000000000000000000;hb=77342950c5f66d1d4700bf48c88f83eedd602849;hpb=ea38fe6b8e92a79a0e473e56cb33b345bdf6456e diff --git a/youtube-html5-hider/script.js b/youtube-html5-hider/script.js new file mode 100644 index 0000000..444afd1 --- /dev/null +++ b/youtube-html5-hider/script.js @@ -0,0 +1,29 @@ +// ==UserScript== +// @name YouTube html5 unembedder +// @namespace http://jasonwoof.com/ +// @description Replace YouTube html5 embedds with links +// @include * +// @exclude http://youtube.com/* +// @exclude http://www.youtube.com/* +// ==/UserScript== + +// Copyright Jason Woofenden 2012. Use as you wish (CC0) + +(function() { + var replace = function(old, replacement) { + old.parentNode.appendChild(replacement); + old.parentNode.removeChild(old); + } + + var iframes = document.getElementsByTagName('iframe'); + for (var i = iframes.length - 1; i >= 0; --i) { + var iframe = iframes[i]; + var match = iframe.src.match(/^http:\/\/www.youtube.com\/embed\/([^?]*)/) + if (match) { + var div = document.createElement('div'); + div.innerHTML = 'YouTube: ' + match[1] + ''; + replace(iframe, div); + } + } +}()); +