2 // @name YouTube html5 unembedder
3 // @namespace http://jasonwoof.com/
4 // @description Replace YouTube html5 embedds with links
6 // @exclude http://youtube.com/*
7 // @exclude http://www.youtube.com/*
10 // Copyright Jason Woofenden 2012. Use as you wish (CC0)
13 var replace = function(old, replacement) {
14 old.parentNode.appendChild(replacement);
15 old.parentNode.removeChild(old);
18 var iframes = document.getElementsByTagName('iframe');
19 for (var i = iframes.length - 1; i >= 0; --i) {
20 var iframe = iframes[i];
21 var match = iframe.src.match(/^http:\/\/www.youtube.com\/embed\/([^?]*)/)
23 var div = document.createElement('div');
24 div.innerHTML = '<a href="http://www.youtube.com/watch?v=' + match[1] + '" style="display: block; width: 200px; height: 20px; padding: 20px; margin: 0; border: 2px dotted #f00; background: #fdd !important; text-align: center; font-size: 16px; font-weight: bold; color: #000">YouTube: ' + match[1] + '</a>';