# Greasemonkey script to view images inline on the SDMB

**URL:** <https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667>\
**Category:** About This Message Board\
**Created:** [July 20, 2011, 3:04am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667 "2011-07-20T03:04:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [July 20, 2011, 3:04am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/1 "2011-07-20T03:04:56Z")

</div>

Below is a Greasmonkey script (that can run in Firefox, and Chrome AFAIK) that enables you to view images inline in the posts in which they appear

The code:

```auto

// ==UserScript==
// @name SDMB inline images
// @namespace Polerius
// @description SDMB inline images
// @include http://boards.straightdope.com/sdmb/*
// ==/UserScript==

(function() 
 {
     var allPosts = document.getElementsByClassName('alt1');

     for (var i = 0; i < allPosts.length; i++)
     {
	 allPosts*.innerHTML = allPosts*.innerHTML.replace(/<a href=\"(http:\/\/[^\"]+)\.(jpg|JPG|png|PNG|gif|GIF)\" target=\"_blank\">([^<]+)<\/a>/g, "<a href=\"$1.$2\" target=\"_blank\">$3</a><img src=\"$1.$2\">");
     }

 })();

```

You can try it out on[this thread](http://boards.straightdope.com/sdmb/showthread.php?t=601384)

Enjoy!

---

<div class="post-metadata">

**Author:** ![Renee](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/renee/32/287_2.png) [@Renee](https://boards.straightdope.com/u/Renee)\
**Post date:** [July 20, 2011, 3:45am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/2 "2011-07-20T03:45:23Z")

</div>

Oh, awesome! Except, I don’t know how to install it? How does that work? I do have greasemonkey and use the other SDMB script, just not sure how to install code like that.

---

<div class="post-metadata">

**Author:** ![needscoffee](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/needscoffee/32/1076_2.png) [@needscoffee](https://boards.straightdope.com/u/needscoffee)\
**Post date:** [July 20, 2011, 4:39am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/3 "2011-07-20T04:39:43Z")

</div>

Yay, it worked!

Renee, are you using Firefox? This is how I did it; I have no idea if there’s supposed to be an easier way. I hope so.

Go into Tools/Greasemonkey/New User Script and then fill in the _Name, Namespace, Description_, and \*Includes \*fields with exactly what is in the code box in Polerius’ OP for those fields.

> [@](#):
>
> \*name \*= SDMB inline images  
> \*namespace \*= Polerius  
> \*description \*= SDMB inline images  
> \*include _= [noparse][Straight Dope Message Board - Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.](http://boards.straightdope.com/sdmb/)_ [/noparse]

Click OK, it will ask you to locate your fave text editor (notepad for you?) and you locate it. It opens up a page for you. Then, from the code box in the OP again, copy everything from (function() to the end of the code box and paste it in the bottom of your new page. Save, and viola!.

---

<div class="post-metadata">

**Author:** ![Renee](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/renee/32/287_2.png) [@Renee](https://boards.straightdope.com/u/Renee)\
**Post date:** [July 20, 2011, 5:04am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/4 "2011-07-20T05:04:32Z")

</div>

OMG, it worked! Thank you both!

---

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [July 20, 2011, 6:11am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/5 "2011-07-20T06:11:49Z")

</div>

> [@Renee](#):
>
> OMG, it worked! Thank you both!

Glad you like it.

Another thread with images: [kittens!](http://boards.straightdope.com/sdmb/showthread.php?t=603029). ETA: It turns out you can see those images even without this script because they are enabled in that forum

---

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [July 20, 2011, 6:35am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/6 "2011-07-20T06:35:22Z")

</div>

> [@Polerius](#):
>
> Another thread with images: [kittens!](http://boards.straightdope.com/sdmb/showthread.php?t=603029). ETA: It turns out you can see those images even without this script because they are enabled in that forum

Since the above wasn’t a good example, here’s another thread with [lots of cats](http://boards.straightdope.com/sdmb/showthread.php?t=519776)

---

<div class="post-metadata">

**Author:** ![needscoffee](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/needscoffee/32/1076_2.png) [@needscoffee](https://boards.straightdope.com/u/needscoffee)\
**Post date:** [July 20, 2011, 6:57am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/7 "2011-07-20T06:57:30Z")

</div>

Are you bucking for a promotion here, or what?

---

<div class="post-metadata">

**Author:** ![CandidGamera](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/candidgamera/32/2878_2.png) [@CandidGamera](https://boards.straightdope.com/u/CandidGamera)\
**Post date:** [July 20, 2011, 2:22pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/8 "2011-07-20T14:22:11Z")

</div>

Sweet, I may give this a try. I seem to recall some earlier SDMB Greasemonkey stuff from years ago; I wonder if it’s collected anywhere.

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [July 20, 2011, 3:33pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/9 "2011-07-20T15:33:07Z")

</div>

> [@needscoffee](#):
>
> Yay, it worked!
> 
> Renee, are you using Firefox? This is how I did it; I have no idea if there’s supposed to be an easier way. I hope so.

Nope. That’s it. The easier way is actually put it into a file.

Well, unless you consider pasting it in Notepad, saving it as sdmbimg.user.js, and then dragging that file into your browser to be easier.

(BTW, that’s how you do it in Chrome.)

---

<div class="post-metadata">

**Author:** ![rowrrbazzle](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rowrrbazzle/32/414_2.png) [@rowrrbazzle](https://boards.straightdope.com/u/rowrrbazzle)\
**Post date:** [July 21, 2011, 2:35am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/10 "2011-07-21T02:35:31Z")

</div>

**Polerius** , great idea!

---

<div class="post-metadata">

**Author:** ![Cicero](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cicero/32/3594_2.png) [@Cicero](https://boards.straightdope.com/u/Cicero)\
**Post date:** [July 21, 2011, 8:47am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/11 "2011-07-21T08:47:54Z")

</div>

Well…

I’m using Firefox but you lost me at Tools/ Greasemonkey…

When I click Tools, I get a drop down menu but Greasemonkey is not there. Is there an additional step. (Or am I looking at the wrong Tools?)

---

<div class="post-metadata">

**Author:** ![Panurge](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@Panurge](https://boards.straightdope.com/u/Panurge)\
**Post date:** [July 21, 2011, 8:53am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/12 "2011-07-21T08:53:52Z")

</div>

Did you install the Greasemonkey extension? You can get it [here](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/).

---

<div class="post-metadata">

**Author:** ![Cicero](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cicero/32/3594_2.png) [@Cicero](https://boards.straightdope.com/u/Cicero)\
**Post date:** [July 21, 2011, 8:59am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/13 "2011-07-21T08:59:38Z")

</div>

Well, I just showed how thick I can be. Thanks **Panurge.**

---

<div class="post-metadata">

**Author:** ![Cicero](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cicero/32/3594_2.png) [@Cicero](https://boards.straightdope.com/u/Cicero)\
**Post date:** [July 21, 2011, 9:13am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/14 "2011-07-21T09:13:48Z")

</div>

And it works. Thanks all.

---

<div class="post-metadata">

**Author:** ![Gukumatz](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@Gukumatz](https://boards.straightdope.com/u/Gukumatz)\
**Post date:** [July 21, 2011, 10:04am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/15 "2011-07-21T10:04:24Z")

</div>

Works great.

Is there a way to automaticaly downscale images? I usually browse zoomed in since I’m sitting in a recliner a good two metres away from the monitor and all those pictures in the cat thread end up being scrollbar-inducingly huge. Is there a way to, say, fix them to a proportion of the screen or automatically downsize images to like 800x600?

Thanks,  
Andy

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [July 21, 2011, 10:38am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/16 "2011-07-21T10:38:15Z")

</div>

The problem is making sure you don’t also upscale images that are smaller than that. But Poleris has out JavaScripted me before, so I wouldn’t be surprised if he thought of something.

---

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [July 21, 2011, 8:47pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/17 "2011-07-21T20:47:18Z")

</div>

> [@Gukumatz](#):
>
> Works great.
> 
> Is there a way to automaticaly downscale images? I usually browse zoomed in since I’m sitting in a recliner a good two metres away from the monitor and all those pictures in the cat thread end up being scrollbar-inducingly huge. Is there a way to, say, fix them to a proportion of the screen or automatically downsize images to like 800x600?

A quick and dirty way to it is to replace the string

```auto

<img src=\"$1.$2\">"

```

in the code in the OP to something like

```auto

<img src=\"$1.$2\" height=\"600px\">"

```

which makes all images be 600 pixels tall. To do anything more intelligent (to make sure you don’t unnecessarily blow up images that are already small) would be more involved.

---

<div class="post-metadata">

**Author:** ![MeanOldLady](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/meanoldlady/32/10737_2.png) [@MeanOldLady](https://boards.straightdope.com/u/MeanOldLady)\
**Post date:** [July 21, 2011, 8:55pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/18 "2011-07-21T20:55:36Z")

</div>

Am I a dork for being excited about trying this when I get home? **Polerius** , wasn’t it you who made the Greasemonkey script to help identify zombies? That one has been rocking my face pretty hard. If it wasn’t you, thanks still for this one, and thanks again to the person who created it!

---

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [July 21, 2011, 8:56pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/19 "2011-07-21T20:56:26Z")

</div>

In case you have a browser that doesn’t support Greasemonkey scripts, or you have an iPhone/iPad, you can get the same effect by adding the following bookmarklet to your browser

```auto

javascript:var allPosts=document.getElementsByClassName('alt1');for (var i = 0; i < allPosts.length; i++){allPosts*.innerHTML = allPosts*.innerHTML.replace(/<a href=\"(http:\/\/[^\"]+)\.(jpg|JPG|png|PNG|gif|GIF)\" target=\"_blank\">([^<]+)<\/a>/g, "<a href=\"$1.$2\" target=\"_blank\">$3</a><img src=\"$1.$2\">");}; void 0;

```

**To add it** : Just visit any website with your browser and bookmark it. Then, edit the bookmark and rename it to something like “See images” and edit the ‘location’ or ‘URL’ property of the bookmark and paste the code from above.

**To use it** : Visit any SDMB thread with images (like[this one](http://boards.straightdope.com/sdmb/showthread.php?t=616653)) and when it finishes loading, simply click the bookmark you made above. Voila! You should now see images embedded in the thread.

I just tried this on my iPhone, and the result is very cool. No need to click on all the individual images to see what they are and then come back to the thread.

---

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [July 21, 2011, 8:58pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/20 "2011-07-21T20:58:00Z")

</div>

> [@MeanOldLady](#):
>
> Am I a dork for being excited about trying this when I get home? **Polerius** , wasn’t it you who made the Greasemonkey script to help identify zombies?

Yep.

ETA: “Yep” was for the second question, not for the “Am I a dork for being excited about trying this when I get home?” 🙂

> [@](#):
>
> That one has been rocking my face pretty hard. If it wasn’t you, thanks still for this one, and thanks again to the person who created it!

Thanks!  
Glad that people are enjoying these.

[Next page](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667.md?page=2)
