# 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:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [July 21, 2011, 9:15pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/21 "2011-07-21T21:15:47Z")

</div>

Never mind, the clever trick I was posting didn’t work.

---

<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 21, 2011, 11:56pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/22 "2011-07-21T23:56:13Z")

</div>

Here are links to two zombie-identifying greasemonkey scripts:  
[http://boards.straightdope.com/sdmb/showpost.php?p=13438467&postcount=60](http://boards.straightdope.com/sdmb/showpost.php?p=13438467&postcount=60)  
[http://boards.straightdope.com/sdmb/showpost.php?p=13510747&postcount=1](http://boards.straightdope.com/sdmb/showpost.php?p=13510747&postcount=1)

---

<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 22, 2011, 11:36pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/23 "2011-07-22T23:36:28Z")

</div>

Success! I am feeling this. Thanks again, **Pol**!

---

<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 23, 2011, 4:20am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/24 "2011-07-23T04:20:36Z")

</div>

Running this script is preventing me from using the multiquote buttons. Nothing happens when I click on the "+ button unless I turn off the new script. I tried all the other scripts individually, but this one is the only one that affects it. Is anyone else having this problem?

---

<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 23, 2011, 2:18pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/25 "2011-07-23T14:18:25Z")

</div>

> [@needscoffee](#):
>
> Running this script is preventing me from using the multiquote buttons. Nothing happens when I click on the "+ button unless I turn off the new script. I tried all the other scripts individually, but this one is the only one that affects it. Is anyone else having this problem?

Yes! I didn’t realize it was the script. I thought the Dope was just being screwy.

---

<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 23, 2011, 7:08pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/26 "2011-07-23T19:08:32Z")

</div>

Multiquote, or kittens? Tough choice.

---

<div class="post-metadata">

**Author:** ![Yookeroo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/yookeroo/32/323_2.png) [@Yookeroo](https://boards.straightdope.com/u/Yookeroo)\
**Post date:** [July 24, 2011, 1:02am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/27 "2011-07-24T01:02:26Z")

</div>

Broke my multiquote button too.

---

<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 24, 2011, 6:07am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/28 "2011-07-24T06:07:38Z")

</div>

> [@needscoffee](#):
>
> Running this script is preventing me from using the multiquote buttons. Nothing happens when I click on the "+ button unless I turn off the new script. I tried all the other scripts individually, but this one is the only one that affects it. Is anyone else having this problem?

I have the same problem. For a quick fix, replace the code in your Greasemonkey script with the following 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++)
     {
	 if(allPosts*.innerHTML.match(/<a href=\"(http:\/\/[^\"]+)\.(jpg|JPG|png|PNG|gif|GIF)\" target=\"_blank\">([^<]+)<\/a>/))
         {
 	      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\">");
         }
     }

 })();

```

The above code ensures that the multiquote button works on all posts that don’t have an inline image. So, for example, it will work on all posts in this thread.

Not a perfect solution, but until I find out a solution that also works for posts with inline images, the above should be good enough. The weird thing is that this seems to be a problem between Greasemonkey and the Multiquote button of vBulletin. [This discussion](http://www.facepunch.com/threads/1051555-Faceraper-2011-for-Greasemonkey/page9)reveals the following

> [@](#):
>
> vBulletin’s built-in multiquote uses a lot of cookie based tomfoolery.

In any case, if I find a more general solution I’ll post it.

---

<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 24, 2011, 6:31am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/29 "2011-07-24T06:31:58Z")

</div>

> [@Polerius](#):
>
> I have the same problem. For a quick fix, replace the code in your Greasemonkey script with the following 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++)
> {
> if(allPosts*.innerHTML.match(/<a href=\"(http:\/\/[^\"]+)\.(jpg|JPG|png|PNG|gif|GIF)\" target=\"_blank\">([^<]+)<\/a>/))
> {
> 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\">");
> }
> }
> 
> })();
> 
> ```
> 
> The above code ensures that the multiquote button works on all posts that don’t have an inline image. So, for example, it will work on all posts in this thread.
> 
> Not a perfect solution, but until I find out a solution that also works for posts with inline images, the above should be good enough. The weird thing is that this seems to be a problem between Greasemonkey and the Multiquote button of vBulletin. [This discussion](http://www.facepunch.com/threads/1051555-Faceraper-2011-for-Greasemonkey/page9)reveals the following  
> In any case, if I find a more general solution I’ll post it.

Thank you.

---

<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 24, 2011, 6:54am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/30 "2011-07-24T06:54:21Z")

</div>

OK, I found the solution to the multiquote problem. Replace the code in the OP with the following code. You can still see images inline, and multiquote works for all posts.  
You can try it on the [kittens thread](http://boards.straightdope.com/sdmb/showthread.php?t=519776)

```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++)
     {
	 var kids = allPosts*.children;
	 for (var j=0; j<kids.length; j++)
	 {
	     if (kids[j].id.match(/^post_message_/))
	     {
		 kids[j].innerHTML = kids[j].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\">");
	     }
	 }

     }
 })();

```

---

<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 25, 2011, 1:43am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/31 "2011-07-25T01:43:27Z")

</div>

Works great!

---

<div class="post-metadata">

**Author:** ![Peremensoe](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@Peremensoe](https://boards.straightdope.com/u/Peremensoe)\
**Post date:** [August 19, 2011, 4:31pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-view-images-inline-on-the-sdmb/589667/32 "2011-08-19T16:31:43Z")

</div>

Hmm. I’d prefer not to see big inline images repeated, though.

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