33

There were previous questions on this already, and according to those it’s also implemented by now. And when looking at the source, I can indeed see an ID being set for every comment on election pages.

However, unlike comments on questions, there is no actual link for the permalink for comments on election pages:

No link for the permalink

Could those be added please so we can actually link to comments easily?

4
  • FWIW, I could do this earlier tonight... but not now. Commented Feb 11, 2014 at 0:03
  • @LightnessRacesinOrbit Interesting. I’m pretty sure I was unable to do so on the election page since it started tonight. Maybe you’re confusing it with a different place on the site?
    – poke
    Commented Feb 11, 2014 at 0:05
  • Nope, I am not. It definitely worked. My one-boxing sparked chatter in chat. But I did have an unfortunate incident with SO CSS (possibly) which may have contributed to my temporary powers. Commented Feb 11, 2014 at 0:11
  • Actually.. you know what? Looking back at the transcript, I may have been thinking of an answer on which comments ensued with one of this year's nominees. Either way, I support this proposal wholeheartedly. Commented Feb 11, 2014 at 0:13

2 Answers 2

6

During the Arqade elections, I wrote a UserScript for this purpose.

It should match for Stack Overflow and Ask Ubuntu (the two current elections), so... should work. Install, go to page, link appears.

Image for demonstration:

These links do not onebox in chat, however, as they're not considered proper comment links like on other posts.

5
  • SE should give some love to them, tho
    – Braiam
    Commented Feb 11, 2014 at 0:54
  • Note that this won’t create actual permalinks, as they are relative to the current site (i.e. /elections, not elections/<id>). You could get the base URL for the current election from something like document.querySelector('.youarehere').href.split('?')[0] though. — That being said, I would prefer having this implemented properly of course, including integration into chat :)
    – poke
    Commented Feb 11, 2014 at 1:37
  • @Braiam SE doesn't want to give them love. This is a feature bug.
    – ɥʇǝS
    Commented Feb 11, 2014 at 1:37
  • @poke It should create the proper permalink if you're on the actual page by ID. I just cba to fetch the ID on the "front page" (if you will) as well.
    – user98085
    Commented Feb 11, 2014 at 1:38
  • Userscript 404s now :o
    – bjb568
    Commented Apr 6, 2015 at 21:12
3

I know it's a bit late for the current elections, but Stack Overflow Unofficial Patch 1.8 now includes a workaround for this bug, loosely based on FEichinger's script.

The core of the workaround is the following jQuery code:

var base = ( $('#tabs .youarehere').attr('href') || "" ).replace( /#.*/, "" );

$('.comment-date').not(':has(a)').wrapInner( function () {
    var id = $(this).closest('.comment').attr('id');
    return $('<a class="comment-link"></a>').attr('href', base + '#' + id);
} );

The base variable ensures that the links will lead to the correct tab (i.e. nominations), even if you haven't explicitly selected a tab. The full workaround included in SOUP also reapplies this fix whenever new comments are dynamically loaded, and also fixes the permalinks below each nomination post to always point at the correct tab.

Note that, due to missing JS support on the nomination pages, these permalinks look and behave somewhat differently than normal SE comment links. In particular, they don't have the same fancy highlight-and-fade behavior as normal comment links, they won't onebox in chat, and they may not work correctly if the comment being linked to is hidden by default.

Alas, these are not issues that can be easily fixed on the client side — even if I added the necessary code to SOUP, it wouldn't help anyone else who might follow the link while not using the same user script.

1
  • 1
    Eww, jQuery. :P
    – user98085
    Commented Mar 14, 2014 at 1:39

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