From 77342950c5f66d1d4700bf48c88f83eedd602849 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Tue, 3 Jan 2012 00:13:41 -0500 Subject: [PATCH] add youtube html5 unembedder --- youtube-html5-hider/manifest.json | 12 ++++++++++++ youtube-html5-hider/script.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 youtube-html5-hider/manifest.json create mode 100644 youtube-html5-hider/script.js 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); + } + } +}()); + -- 1.7.10.4