celerym / RedditCommentProfiles

// ==UserScript==
// @name         RedditCommentProfiles
// @namespace    https://www.reddit.com/r/celerym/
// @version      0.3
// @description  Sticks Reddit User Profile images to comments, where available.
// @author       celerym
// @match        https://*.reddit.com/r/*/comments/*
// @grant        none
// @homepageURL  https://www.reddit.com/r/celerym/
// @supportURL   https://www.reddit.com/r/celerym/
// ==/UserScript==

// Adjust the profile image size:
var rcp_img_size = '50px';

(function() {
    'use strict';
     $('.commentarea .entry').each(function() {
        var blanko = "https://www.reddit.com/static/pixel.png";
        $(".usertext-body", this).prepend("<img src='"+blanko+"' class='rcp_image' style='display:none;'/>");
        var rcp_user = $(".author", this).text();
        var rcp_img = $(".rcp_image", this);
        $.get('https://www.reddit.com/user/'+rcp_user, function(data) {
            rcp_img.attr('src', $(data).find('.ProfileSidebar__usericon-image').attr('src'));
            if (rcp_img.attr('src') !== blanko) {
                rcp_img.attr('style', 'float:left;display:inline-block;margin-right:10px;width:'+rcp_img_size+';height:auto;');
            } 
        });
    });
})();