-
-
Save Dakta/4103917 to your computer and use it in GitHub Desktop.
Bookmarklet to add inline full-size images to Reddit.
This file contains hidden or 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 () { | |
var things = document.querySelectorAll("div.thing"); | |
for (var j = 0; j < things.length; j++) { | |
var thing = things[j], | |
entry = thing.querySelectorAll("div.entry")[0], | |
thumb = thing.querySelectorAll("a.thumbnail")[0], | |
img = new Image; | |
img.style.display = 'block'; | |
img.style.width = '100%'; | |
if (thumb) { | |
var href = thumb.href; | |
if (/\.(png|gif|jpg)$/i.test(href)) img.src = href; | |
else if (/imgur\.com/i.test(href)) { | |
var id = /\w+?$/.exec(href)[0]; | |
img.src = "http://i.imgur.com/" + id + ".jpg"; | |
} else if (/picsarus\.com/i.test(href)) { | |
var id = /\w+?$/.exec(href)[0]; | |
img.src = "http://picsarus.com/" + id + ".jpg"; | |
} | |
if (img.src) entry.appendChild(img); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment