98

Screenshot

reply links on comments

About

This user script adds a little "reply" link to each comment. Clicking this link will

  1. fetch the rest of the comments, if some of them were hidden
  2. show the "add comment" text box
  3. pre-populate the text box with "@" and the name of the user you're replying to (removing spaces).

Be aware that there's no guarantee that the replied-to user will be notified of the comment -- all the @-reply caveats still apply (see the blog or the community faq for some information).

Download

install / update scriptview source

Platform

I have tested this script in Chrome (Windows 7), Chromium (Fedora 14), and Firefox + Greasemonkey (both OSes).

Contact

This script is created by Benjamin Dumke-von der Ehe. Note that this is a free-time project of mine, and has nothing to do with my employment at Stack Overflow. See my profile for contact details; you can also often find me in the Tavern on Meta Stack Exchange chat.

15
  • The script somehow seems to swallow certain characters at times, e.g. infensus was turned into inensus.
    – brunnerh
    Commented Aug 2, 2011 at 1:31
  • Please make it work with other sites as well.
    – LifeH2O
    Commented Aug 8, 2011 at 14:51
  • Loving this script, especially after a couple minor tweaks
    – freiheit
    Commented Aug 13, 2011 at 18:54
  • How is this script affected by Tab name completion for comments please!? Will you still maintain it?
    – tshepang
    Commented Jan 25, 2012 at 22:28
  • 1
    @Tshepang: It still works, and I'm still using it myself. I have found myself using the tab completion more and more, but I also still use this script.
    – balpha Staff
    Commented Jan 26, 2012 at 7:30
  • This does not work with usernames which contain only non-ascii characters like in tex.stackexchange.com/q/74494/5763: When replying to "ガベージコレクタ" the script eats the complete username (with FF15 on Win7). Commented Sep 28, 2012 at 13:26
  • @MartinSchröder Ah yeah, I never fixed that... (To be honest, I haven't been using this script much since we put the tab autocompleter in). I'll fix it over the weekend; it's easy enough.
    – balpha Staff
    Commented Sep 28, 2012 at 14:17
  • @MartinSchröder Fixed now.
    – balpha Staff
    Commented Sep 30, 2012 at 17:22
  • 2
    Now (v1.1) it doesn't open the comment field anymore; it still adds the arrow and when the comment field is open the user name is added. Commented Aug 9, 2014 at 21:28
  • 3
    Please address the bug with not opening the command field anymore Commented Mar 30, 2015 at 22:39
  • 1
    I fixed the bug and submitted pull request to @balpha. See bitbucket.org/MNF/user-scripts/src/… Commented Jan 30, 2016 at 10:59
  • The script was last updated on 2014-06-11. See this bug report and Michael Freidgeim's comment.
    – user598527
    Commented Oct 21, 2017 at 10:15
  • 1
    The Bitbucket repo is down.
    – user598527
    Commented Feb 5, 2022 at 14:27
  • Is it possible for you to copy the source code in this question itself? So that we can use it. The Bitbucket repo is currently down as another user has mentioned. This applies to your other posts as well.
    – Himanshu
    Commented May 24, 2022 at 7:59
  • 2
    Repository not found... Commented Aug 2, 2023 at 5:35

6 Answers 6

10


Clicking on the icon won't reveal the comment-box anymore.

One has to click the "add comment" link, for the comment box to appear, then click on the script icon to add the reply signature into the revealed comment-box.

1
8

I would like to suggest

  1. Add stackapps.com to list of sites
  2. Allow the common "upside-down" unicode characters that have become trendy lately (and some users are using in their names now).
  3. Allow basic greek alphabet, since that also seems popular (lot of math and science symbols are greek)

Diff format, tested and working for me in Chrome:

--- 68252.user.js.orig  2011-08-13 11:15:22.000000000 -0700
+++ 68252.user.js   2011-08-13 11:51:49.000000000 -0700
@@ -15,6 +15,7 @@
 // @include        http://meta.answers.onstartups.com/*
 // @include        http://mathoverflow.net/*
 // @include        http://area51.stackexchange.com/proposals/*
+// @include        http://stackapps.com/*
 // @author         Benjamin Dumke
 // ==/UserScript==

@@ -82,7 +83,13 @@
                             ,'\u00e0','\u00e1','\u00e2','\u00e3','\u00e4','\u00e5','\u00e6','\u00e7'
                             ,'\u00e8','\u00e9','\u00ea','\u00eb','\u00ec','\u00ed','\u00ee','\u00ef'
                             ,'\u00f1','\u00f2','\u00f3','\u00f4','\u00f5','\u00f6'         
-                            ,'\u00f8','\u00f9','\u00fa','\u00fb','\u00fc','\u00fd'         ,'\u00ff').join('');
+                            ,'\u00f8','\u00f9','\u00fa','\u00fb','\u00fc','\u00fd'         ,'\u00ff'
+                            // upside-down lowercase from http://www.fileformat.info/convert/text/upside-down-map.htm
+                            ,'\u0250','\u0254','\u01dd','\u025f','\u0183','\u0265','\u0131','\u027e'
+                            ,'\u029e','\u0283','\u026f','\u0279','\u0287','\u028c','\u028d','\u028e'
+                            // basic greek http://en.wikipedia.org/wiki/Greek_alphabet
+                            ,'\u0370-\u03FF'
+                            ).join('');

     var bad = new RegExp("[^" + goodletters + "\\w.'-]", "ig");
2
  • 2
    Upside-down and greek because the hard-to-type usernames are exactly the ones I want to use a reply button for.
    – freiheit
    Commented Aug 13, 2011 at 19:37
  • 2
    Actually, all this script (in its current version) really needs is to remove spaces, so the character whitelist isn't really necessary anymore (I really thought I had made this change already, but it looks like I never did). I'll add your characters to stackapps.com/questions/2050/threaded-comments, though. And good point about updating the site list; will do. Thanks!
    – balpha Staff
    Commented Aug 13, 2011 at 20:20
3

I've made a couple of fixes to make this work again. While I don't fork and ask for a merge, here it is a copy of my script for convenience, the modifications are indicated with comments. The matches of sites has been revised as well.

// ==UserScript==
// @name           stackoverflow-comment-reply
// @namespace      stackapps
// @description    Add "reply" links to comments
// @version        1.1c
// @match          *://*.askubuntu.com/*
// @match          *://*.mathoverflow.net/*
// @match          *://*.serverfault.com/*
// @match          *://*.stackapps.com/*
// @match          *://*.stackexchange.com/*
// @match          *://*.stackoverflow.com/*
// @match          *://*.superuser.com/*
// @match          *://area51.stackexchange.com/proposals/*
// @author         Benjamin Dumke-von der Ehe
// ==/UserScript==

/* MOD: don't run if not SE and user not logged in */
if (!window.StackExchange || window.StackExchange.options.user.isAnonymous )
    return;

// Thanks to Shog9 for this idea for making the script work in both
// Chrome and Firefox:
// http://meta.stackoverflow.com/questions/46562
function with_jquery(f) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.textContent = "(" + f.toString() + ")(jQuery)";
    document.body.appendChild(script);
};

with_jquery(function($) {

    $(document).ajaxComplete(function(){
        setTimeout(function () {
            $(".comments").each(put_reply_links);
        }, 100);
    });

    // event handler for a click on the reply links
    function reply() {
        /* MOD: changed the following 2 lines to detect the new Add Comment link */
        var commentlinkId = $(this).closest(".comments").next().attr("id");
        var commentlink = $('#'+commentlinkId + ' a.js-add-link')[0].click();
        var username = goodify($(this).prev().text().replace(/♦/, ""))
        var formid = commentlinkId.replace(/^.*-(\d+)$/, "add-comment-$1");
        var ta = $("#" + formid + " textarea")[0];
        var start = ta.selectionStart;
        var end = ta.selectionEnd;
        var shift = username.length + 3;
        ta.value = "@" + username + ": " + ta.value;
        ta.focus();
        ta.selectionStart = start + shift;
        ta.selectionEnd = end + shift;
    };

    function put_reply_links() {
        $(this).find(".comment:not(:has(.reply-link)) .comment-user").each(function () {
            /* MOD: // changed click by on(click) */
            $("<span class='reply-link' style='cursor:pointer;opacity:0.3' title='reply'> &crarr;</span>").on('click',reply).insertAfter(this); 
        });
    }

    $(".comments").each(put_reply_links);

    function goodify(s) {
        return s.replace(/ +/g, "");
    }   
});
3

Unable to click on Comment. When i click on the icon then it doesn't show comment box.

1
2


You need to open the comment box before clicking the arrow. If you need to click the comment box, I think starting tagging user from keyboard is quicker than move your mouse to click the arrow, then start typing the comment.

4
  • It was a bug, not an intentional behavior. I fixed it at bitbucket.org/MNF/user-scripts/src/… Commented Jan 30, 2016 at 11:02
  • @MichaelFreidgeim how do I use it?
    – Ooker
    Commented Jan 30, 2016 at 11:15
  • In Chrome, install and open Tampermonkey, then copy my script from bitbucket, save it and insure it shown as Installed Userscript. Then refresh any stackoverflow page and you will see arrows on each comment. For other browsers there are different extensions to run Userscripts greasyfork.org/en/help/installing-user-scripts Commented Jan 30, 2016 at 11:37
  • @MichaelFreidgeim: it works. Thanks for your effort.
    – Ooker
    Commented Jan 30, 2016 at 11:56
1

Any chance you could update this again? As noted by several others, clicking the reply link doesn't show the comment field, but if you manually click the "add a comment" link it works fine. So the thing is, if you have to manually click "add a comment", in most cases it's then easier to use Stack Exchange's tab completion feature than to click the reply button. My issue is that once I click "add a comment", I often forget to add the @mention I want at the beginning until I've already written some of my response, and if I go back to the beginning of my comment to add it, the tab completion no longer works.

Also, the last update was made about 4 years ago, and it's been broken since about 3 months after that.

All it needs to be able to do this is to have the following line added on a line after commentlinkId is defined and before ta is defined:

$("#" + commentlinkId + " a").click();

Also an update to the list of @match rules would be nice. This should work for all current Stack Exchange sites (including area51):

// @match          *://*.stackoverflow.com/*
// @match          *://*.serverfault.com/*
// @match          *://*.superuser.com/*
// @match          *://*.stackapps.com/*
// @match          *://*.stackexchange.com/*
// @match          *://*.askubuntu.com/*
// @match          *://*.mathoverflow.net/*

You must log in to answer this question.

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