Skip to content

Instantly share code, notes, and snippets.

@heavyLobster2
Last active December 2, 2021 23:11
Show Gist options
  • Save heavyLobster2/c7df692023ebab3729bc to your computer and use it in GitHub Desktop.
Save heavyLobster2/c7df692023ebab3729bc to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hide Reddit Comment Box
// @description Hides the Reddit comment box
// @version 1.0.6
// @author heavyLobster2
// @namespace github.com/heavyLobster2
// @downloadURL https://gist.github.com/heavyLobster2/c7df692023ebab3729bc/raw/HideRedditCommentBox.user.js
// @include *://*.reddit.com/r/*/comments/*
// @grant none
// ==/UserScript==
(function () {
"use strict";
var style = document.createElement("style");
style.type = "text/css";
document.head.appendChild(style);
style.sheet.insertRule("section.commentsignupbar { display: none !important; }");
style.sheet.insertRule("div.commentarea > div.usertext { margin-bottom: 4px !important; }");
var commentForm = document.querySelector("div.commentarea > form.usertext");
if (commentForm) {
var toggleLink = document.createElement("a");
toggleLink.href = "#";
var toggleDiv = document.createElement("div");
toggleDiv.appendChild(toggleLink);
var commentContainer = document.createElement("div");
commentContainer.classList.add("usertext");
commentContainer.appendChild(toggleDiv);
commentForm.parentNode.replaceChild(commentContainer, commentForm);
commentContainer.appendChild(commentForm);
var showing = true;
var toggle = function () {
if (showing) {
toggleLink.textContent = "Post a new comment";
commentForm.style.display = "none";
showing = false;
} else {
toggleLink.textContent = "Cancel new comment";
commentForm.style.display = "";
showing = true;
}
return false;
};
toggleLink.onclick = toggle;
toggle();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment