I just tried to link some comment from the election page only to find out there is no link on the timestamp.

Is this by design? If so: can this be reconsidered. Sometimes I want to link to comments in chat which is not easy to do now.

To make my question a bit less dupe. The comments once linked by doing heavy manual labor (looking up the id in the DOM) also don't onebox in chat.

  • Also, clicking the link button on the post actually opens the link, rather than the fancy copy-paste box like we all expect. Sad pandas are sad!
    – animuson StaffMod
    Feb 25 '13 at 22:50
  • Crap :( As always I see a dupe once I've posted my question. I have searched and I have glanced the dupe list when entering my title. Really... :)
    – PeeHaa
    Feb 25 '13 at 22:50
  • And meta.stackexchange.com/questions/135225/…
    – Bart
    Feb 25 '13 at 22:55
  • 1
    Yesyesyes. Was going to post my own feature request for this. Comment permalinking is a somewhat new feature, but there's no place where it makes more sense than the elections page. There's tons of comments there -- the feature is basically overloaded to be used as a forum thread.
    – jscs
    Feb 26 '13 at 6:31
  • @Oded - The status is completed now! Sep 20 '13 at 11:33
  • 1
    @Oded the status is uncompleted. We can't get a permalink for comments on the recent ELL's election. (Or wait, was this just for Stack Overflow elections?)
    – M.A.R.
    Aug 28 '15 at 18:13
  • @Oded it also doesn't work on the recent Anime elections.
    – Catija StaffMod
    Aug 28 '15 at 18:44

Not yet thoroughly tested. I confirm that it supports the case of loading more comment, and it should also support posting/deleting comment.

I have made some updates since my first revision to fix some bugs.

This is currently Revision 3

// ==UserScript==
// @name           Timestamp in Election comment
// @namespace      nhahtdh
// @include        http://stackoverflow.com/election*
// @grant          metadata
// @author         nhahtdh

function with_jquery(f) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.textContent = "(" + f.toString() + ")(jQuery)";

with_jquery(function ($) {
    function addCommentLink(ref) {
        $('.comment', ref).each(function () {
            $('.comment-date > .relativetime-clean', this).wrapAll($('<a href="' + '#' + this.id + '"></a>'));


    $(document).ajaxComplete(function (e, xhr, settings) {
        if (/\/comments/.test(settings.url)) {

You can construct a URL that will point to a comment.

All you need is to take a look at the id of the actual comment -


It's not too comfortable, and a little hacky... but it works never-the-less!

  • I know I can look it up in the DOM (that's the part about not be easy). I should have added that in my question. Sorry that I suck at this :(
    – PeeHaa
    Feb 25 '13 at 22:52
  • 2
    I smell a userscript brewing ;)
    – Lix
    Feb 25 '13 at 22:53
  • @PeeHaa - Nothing feels better than finding someone else has already done your work ;)
    – Lix
    Feb 25 '13 at 23:00
  • Why are you referring to me as pee. That's very offensive! Especially bad when you are running for mod! Flagged! ;)
    – PeeHaa
    Feb 25 '13 at 23:03
  • @PeeHaa - sorry for that.. I'm used to using the minimum 3 character @ replies...
    – Lix
    Feb 25 '13 at 23:04
  • Also it seems that Manishearth's script doesn't work any more...
    – Lix
    Feb 25 '13 at 23:05
  • 2
    That's ok. I forgive you :-) Would be nice if this would be "fixed" though at some point imho (the functionality I mean although a userscript could be a temporary solution).
    – PeeHaa
    Feb 25 '13 at 23:09
  • 2
    @Lix It works, but only on the visible comments. Doesn't work on comments that show up after you click "add / show n more comments".
    – yannis
    Feb 25 '13 at 23:24

Put your hands in the air like you just don't care (for such crass abstractions as jQuery)

Edit: slight improvement to expando link callback to prevent multiple calls and wait until all additional comments have been loaded

// ==UserScript==
// @name Election comment linkifier
// @description Linkify comment timestamps in SO moderator election
// @version 1.0
// @author DaveRandom
// @namespace https://github.com/DaveRandom
// @match http://stackoverflow.com/election/*
// ==/UserScript==

(function() {

  function addLinksToUnprocessedPosts() {
    var i, l, linkSpan, linkText, anchorElement,
        comments = document.querySelectorAll('tr[id^=comment-]:not(.linkmaker-processed)');

    pending = false;

    for (i = 0, l = comments.length; i < l; i++) {
      linkSpan = comments[i].querySelector('span.comment-date span');
      linkText = linkSpan.firstChild;

      anchorElement = document.createElement('a');
      anchorElement.href = '#' + comments[i].id;


      comments[i].className += ' linkmaker-processed';

  var i, l, pending = false,
      expandoLinks = document.querySelectorAll('.comments-link');
  for (i = 0, l = expandoLinks.length; i < l; i++) {
    expandoLinks[i].parentNode.querySelector('tbody').addEventListener('DOMNodeInserted', function(e) {
      if (e.srcElement.nodeType === 1 && e.srcElement.tagName.toLowerCase() === 'tr' && !pending) {
        pending = true;
        setTimeout(addLinksToUnprocessedPosts, 0);


Tested in a real browser (Google Chrome), but I suppose if you must you may sully my fine craftsmanship by using it in that other one...

  • 1
    Good guy Dave strikes again!
    – PeeHaa
    Feb 26 '13 at 0:09
  • DOMNodeInserted event is deprecated, at least according to MDN
    – nhahtdh
    Feb 26 '13 at 0:15
  • 2
    @nhahtdh Indeed it is, and for very good reasons. However the main problem is with bubbling - not too much of a problem because the node(s) I attached it to have very few child nodes and they don't really change apart from when you click the link. The alternative (mutation observers) is, however, a lot more of a pita to work with. I agreed it's not an ideal mechanism but the other option - without resorting to jQuery - was to poll the DOM for completion which is even more horrible (IMO). Side note: the way in which the SE code deals with adding the extra posts to the DOM is very inefficient. Feb 26 '13 at 0:24
  • @DavidX.Random: +1 for a great comment. I don't code web-related stuffs much, so this is great insight.
    – nhahtdh
    Feb 26 '13 at 0:28
  • 2
    @nhahtdh In a couple of years (hopefully) MutationObserver will be the way to do things like this but at the moment it is only supported in Chrome and Firefox, and in Chrome it uses a non-standard name (Webkit prefix). Mutation events are very inefficient on the DOM (especially in Firefox) which is why they have been deprecated but for real-world applications where cross browser support is required, i.e. not little overlays like this, unfortunately you are stuck with them at the moment. I started work on an observer abstraction with fallback to events a while ago, but it doesn't work yet. Feb 26 '13 at 0:36

You must log in to answer this question.

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