From: Jason Woofenden Date: Tue, 3 Jan 2012 05:13:41 +0000 (-0500) Subject: add youtube html5 unembedder X-Git-Url: https://jasonwoof.com/gitweb/?p=userscripts.git;a=commitdiff_plain;h=77342950c5f66d1d4700bf48c88f83eedd602849 add youtube html5 unembedder --- diff --git a/youtube-html5-hider/manifest.json b/youtube-html5-hider/manifest.json new file mode 100644 index 0000000..d1abc0b --- /dev/null +++ b/youtube-html5-hider/manifest.json @@ -0,0 +1,12 @@ +{ + "content_scripts": [ { + "exclude_globs": [ "http://youtube.com/*", "http://www.youtube.com/*" ], + "include_globs": [ "*" ], + "js": [ "script.js" ], + "matches": [ "http://*/*", "https://*/*" ], + "run_at": "document_idle" + } ], + "description": "Replace YouTube's html5 \"embedded\" videos into links", + "name": "YouTube html5 unembedder", + "version": "1.0" +} 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); + } + } +}()); +