Topic: [Feature] 1 less step when writing comments

Posted under General

Requested feature overview description.
When clicking on the "post comment" button under a post; have the cursor automatically focus on the text box

Why would it be useful?
As starting a comment works now, you have to first click on the text that says "post comment" and then click on the text box to start writing you comment. This has led me to start typing as soon as i click on "post comment" only to press random hotkeys and inevitably finding myself bringing up the edit box, and sometimes unintentionally upvote, downvote, or favorite the post i'm commenting on

while this isn't a massive issue, it's annoying enough that i want to see it change

What part of the site page are affected?
the comment section of posts and the comment page (this could also be implemented in forum topics since it's basically the same code, but i feel that it's less destructive here than on a post)

Updated

i made this userscript in around 10 minutes. i don't really code in javascript so, it probably isn't up to snuff. it focuses the body text on both forum and post replies. let me know if it doesn't work, i have my own scripts to change the functionality to appease my sense of taste which might interfere with this.

// ==UserScript==
// @name        Focus textarea
// @match       http*://*.e621.net/forum_topics/*
// @match       http*://*.e621.net/posts/*
// @grant       none
// @author      e621.net/users/256509
// ==/UserScript==

var postReplyLink = document.getElementsByClassName("expand-comment-response")[0];
if (postReplyLink != null) {
    console.log(postReplyLink.innerHTML);
    postReplyLink.addEventListener("click", function(event) {
        event.preventDefault();
        setTimeout(function() {
            document.getElementById("comment_body_for_").focus();
        }, 50);
    });
}
else {
    var forumReplyLink = document.getElementById("new-response-link");
    if (forumReplyLink != null) {
        forumReplyLink.addEventListener("click", function(event) {
            event.preventDefault();
            setTimeout(function() {
                document.getElementById("forum_post_body_for_").focus();
            }, 50);
        });
    }
}

likulau said:
i made this userscript in around 10 minutes. i don't really code in javascript so, it probably isn't up to snuff. it focuses the body text on both forum and post replies. let me know if it doesn't work, i have my own scripts to change the functionality to appease my sense of taste which might interfere with this.

da code
// ==UserScript==
// @name        Focus textarea
// @match       http*://*.e621.net/forum_topics/*
// @match       http*://*.e621.net/posts/*
// @grant       none
// @author      e621.net/users/256509
// ==/UserScript==

var postReplyLink = document.getElementsByClassName("expand-comment-response")[0];
if (postReplyLink != null) {
    console.log(postReplyLink.innerHTML);
    postReplyLink.addEventListener("click", function(event) {
        event.preventDefault();
        setTimeout(function() {
            document.getElementById("comment_body_for_").focus();
        }, 50);
    });
}
else {
    var forumReplyLink = document.getElementById("new-response-link");
    if (forumReplyLink != null) {
        forumReplyLink.addEventListener("click", function(event) {
            event.preventDefault();
            setTimeout(function() {
                document.getElementById("forum_post_body_for_").focus();
            }, 50);
        });
    }
}

it works perfectly and i'd upvote this reply if i could

(i mean an emoji counts, right?)

๐Ÿ‘

  • 1