Created
March 14, 2012 20:47
-
-
Save marcoos/2039390 to your computer and use it in GitHub Desktop.
Bookmarklet replacing oldschoold YouTube Flash embeds with the iframe-based HTML5 embeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replaces obsolete Flash-based embeds of YouTube video | |
// with new embeds using HTML5. | |
// | |
// Useful, if you don't have Flash. | |
(function () { | |
var i, | |
videoId, | |
frame; | |
embeds = document.querySelectorAll("embed[src^='http://www.youtube.com/v/']"); | |
for (i = 0; i < embeds.length; i++) { | |
try { | |
videoId = (/youtube.com\/v\/([a-zA-Z0-9]+)/).exec(embeds[i].src)[1]; | |
frame = document.createElement("iframe"); | |
frame.width = 640; | |
frame.height = 385; | |
frame.style.border = 0; | |
frame.src = "http://www.youtube.com/embed/" + videoId; | |
embeds[i].parentNode.replaceChild(frame, embeds[i]); | |
} catch (e) {} | |
} | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){var i,videoId,frame;embeds=document.querySelectorAll("embed[src^='http://www.youtube.com/v/']");for(i=0;i<embeds.length;i++){try{videoId=(/youtube.com\/v\/([a-zA-Z0-9]+)/).exec(embeds[i].src)[1];frame=document.createElement("iframe");frame.width=640;frame.height=385;frame.style.border=0;frame.src="http://www.youtube.com/embed/"+videoId;embeds[i].parentNode.replaceChild(frame,embeds[i]);}catch(e){}}}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2012 Marek Stepien <marek.stepien@gmail.com> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go to http://jsfiddle.net/marcoos/RTRVj/embedded/result/ if you just want to install this bookmarklet.