Skip to content

Instantly share code, notes, and snippets.

@DannyJoris
Created September 17, 2014 15:37
Show Gist options
  • Save DannyJoris/192781582175b9822ab7 to your computer and use it in GitHub Desktop.
Save DannyJoris/192781582175b9822ab7 to your computer and use it in GitHub Desktop.
Bookmarklet to convert a gif URL or the first gif image in a DOM to gfy: http://hastebin.com/raw/quzumamebe / compressed with: http://jscompress.com/
javascript:(function(){
// if URL is gif
if (checkGifURL(document.URL)) {
window.location.replace("http://gfycat.com/fetch/" + document.URL);
}
// first gif in DOM
else {
var imgs = document.getElementsByTagName("img");
for (var i = 0; i < imgs.length; i++) {
if (checkGifURL(imgs[i].src)) {
window.location.replace("http://gfycat.com/fetch/" + imgs[i].src);
}
}
}
function checkGifURL(url) {
return(url.match(/\.(gif)$/) != null);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment