What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

Install it on userscripts here


The posts of the person who asked the question are highlighted in blue, so why can't our own posts be highlighted? It makes finding my stuff much easier. Highlights anything that links to your user-profile (comments, answers, etc.)

any and all feedback or suggestions welcome!

source:

// ==UserScript==
// @name           Highlight your username on SOFU
// @namespace      CrazyJugglerDrummer
// @description    highlights wherever your username appears on the page
// @include        http://stackoverflow.com/*
// @include        http://superuser.com/*
// @include        http://serverfault.com/*
// @include        http://meta.stackoverflow.com/*
// ==/UserScript==

var userLink = document.getElementById("hlinks-user").getElementsByTagName("a")[1].href;

var links = document.getElementsByTagName("a");

for (var x=0; x<links.length; x++) {
    if ( links[x].href == userLink ) {
        links[x].style.color = "#f00"; 
        links[x].style.backgroundColor="#fcc";
    }
}
share|improve this question
1  
Nice. My Question Dashboard meta.stackexchange.com/questions/31486/… script may be a nice compliment to yours - one feature, among others, is the indicator "Me" which appears if an Answer, Question or Comment of yours exists on the current page. –  micahwittman Jan 8 '10 at 7:15
3  
can this please be moved to stackapps.com/?tab=scripts as necessary? Or flag for deletion. –  Jeff Atwood Jul 31 '11 at 22:53
    
Just one change; var userLink = document.getElementById("hlinks-user").getElementsByTagName("a")[1].href; highlights reputation. Changing the 1 to a 0, though, highlights the username. Cheers! –  ChrisForrence Oct 4 '13 at 20:15
add comment

2 Answers 2

up vote 2 down vote accepted

I love this idea.

I submitted it as a feature-request a few months ago: Highlight our own comments, too.

Vote it up. I would love to see it implemented natively.

share|improve this answer
add comment

+1 for the script and for the request to implement this natively :)

It apparently doesn't work anymore (hlinks-user doesn't exist anymore).

I have modified the script as follows (it highlights the whole post/comment, only tested in Chrome)

// ==UserScript==
// @name           Highlight your username on SOFU
// @namespace      CrazyJugglerDrummer
// @description    highlights wherever your username appears on the page
// @include        http://stackoverflow.com/*
// @include        http://superuser.com/*
// @include        http://serverfault.com/*
// @include        http://meta.stackoverflow.com/*
// ==/UserScript==

// Loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
  var script = document.createElement("script");
  script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  script.addEventListener('load', function() {
    var script = document.createElement("script");
    script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();"; // jQ replaces $ to avoid conflicts.
    document.body.appendChild(script);
  }, false);
  document.body.appendChild(script);
}

// The main content of this userscript
function main() {
    var HighlightUserPosts = function(){
        jQ("a[href='"+userLink+"']").each(function(){
          jQ(jQ(this).parents('tr.comment, div.question > table > tbody > tr, div.answer > table > tbody > tr')[0]).css('background-color','#efe');
        });
    }

    var userLink = jQ('a.profile-me').attr('href');
    HighlightUserPosts();
    setTimeout(HighlightUserPosts, 2500); // Fire again after SOFU's highlight fades away
}

// Load jQuery and execute the main function
addJQuery(main);
share|improve this answer
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .