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);
19 {tag: 'iframe', attr: 'src'},
20 {tag: 'object', attr: 'data'},
21 {tag: 'embed', attr: 'src'}
25 for(i = 0; i < embed_types.length; ++i) {
26 var tag_type = embed_types[i].tag;
27 var attr = embed_types[i].attr
29 var tags = document.getElementsByTagName(tag_type);
30 for(var j = tags.length - 1; j >= 0; --j) {
33 var match = tag[attr].match(/^http:\/\/www.youtube(-nocookie)?.com\/(embed|v)\/([^?]*)/)
35 var div = document.createElement('div');
36 div.innerHTML = '<a href="http://www.youtube.com/watch?v=' + match[3] + '" 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[3] + '</a>';