Skip to content

Instantly share code, notes, and snippets.

@tallykatt
Forked from chetan/bookmarklet.js
Created July 24, 2016 23:35
Show Gist options
  • Save tallykatt/93380e4caa4bdd61af9dc042b892a470 to your computer and use it in GitHub Desktop.
Save tallykatt/93380e4caa4bdd61af9dc042b892a470 to your computer and use it in GitHub Desktop.
youtube unblocker bookmarklet
javascript:(function(){var%20s=document.createElement('script');s.setAttribute('src','https://code.jquery.com/jquery-2.1.1.min.js');s.setAttribute('type','text/javascript');document.getElementsByTagName('head')[0].appendChild(s);$jq=jQuery.noConflict();$jq("a").each(function(i,el){var%20href=$jq(el).attr("href");var%20matches=href?href.match(/youtube.com\/watch\?.*?v=([a-zA-Z0-9_\-]+)/):null;if(matches){$jq(el).attr("href","https://www.youtube-nocookie.com/embed/"+matches[1]);}});$jq("iframe").each(function(i,el){var%20src=$jq(el).attr("src");var%20matches=src?src.match(/youtube.com\/embed\/([a-zA-Z0-9_\-]+)\??/):null;if(matches){$jq(el).attr("src","https://www.youtube-nocookie.com/embed/"+matches[1]);}});})();
// http://ted.mielczarek.org/code/mozilla/bookmarklet.html
var s = document.createElement('script');
s.setAttribute('src', 'https://code.jquery.com/jquery-2.1.1.min.js');
s.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
$jq = jQuery.noConflict();
$jq("a").each(function(i, el) {
var href = $jq(el).attr("href");
var matches = href ? href.match(/youtube.com\/watch\?.*?v=([a-zA-Z0-9_\-]+)/) : null;
if (matches) {
$jq(el).attr("href", "https://www.youtube-nocookie.com/embed/" + matches[1]);
}
});
$jq("iframe").each(function(i, el) {
var src = $jq(el).attr("src");
var matches = src ? src.match(/youtube.com\/embed\/([a-zA-Z0-9_\-]+)\??/) : null;
if (matches) {
$jq(el).attr("src", "https://www.youtube-nocookie.com/embed/" + matches[1]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment