Created
September 17, 2014 15:37
-
-
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/
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
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