BodyBuilding and Userscripts

19 Jul 2013

For my get sexy goal, I used a lot. It really helped me with both my diet and my workout, and it helped me to filter out all of the bro science that floats around out there. The best part of the site is the forum, and while like any forum there is a lot of misinformation coming from people that are wrong or just fuzzy on an idea, I would say that there is an equal number of people that are skeptics, and demand studies for proof that something is or isn’t effective.

Outside of looking for advice to help me shape my lifestyle, there are several body transformation threads with before and after pictures. As much as I love this thread, I noticed a deficiency in that on most posts the images are linked to like an attachment. This means that you need to open them in a new tab, and it certainly slows down mindless browsing. I decided to write a userscript (use with greasemonkey or tampermonkey) to let me avoid the hassle of opening these images in a new tab. The result is below.

It’s a pretty simple script that runs only on pages. Replaces the inline links to images with their source being set to the href of the original link.

// ==UserScript==
// @name       Body Building Forum Enhancer
// @namespace
// @require
// @version    0.1
// @description  Changes links to media to embedded media.
// @match*
// @copyright  2013+, Gary Borton
// ==/UserScript==

    var fileTypes = [".jpg", ".jpeg", ".png", ".gif"];
    var allLinks = $('a');

        var element = $(this);

        if (validImageLink(element)) {
            element.replaceWith("<img src=\""+$(this).attr('href')+"\">"+$(this).text()+"</img>");


    function validImageLink(element) {

        var returnValue = false;

        $.each(fileTypes, function(index, value) {
            if (element.text().toLowerCase().indexOf(value) > -1) {
                returnValue = true;
                return false; // Breaks the jQuery loop

        return returnValue;

Link to the repo -