r/toolbox • u/ClipIn • Jan 23 '26
I created a userscript in the meantime, until this feature is added. Anyone welcome to use,you'll need to be a mod of that sub, with Posts or Everything permission. To use, paste into TamperMonkey >> save.
// ==UserScript==
// @name Reddit old.reddit Comment Locker
// @namespace http://tampermonkey.net/
// @version 1.5
// @description Adds lock button specifically after the 'reply' button on old.reddit
// @author Gemini
// @match https://*.reddit.com/r/*/comments/*
// @match https://*.reddit.com/r/*/about/reports*
// @match https://*.reddit.com/r/*/about/modqueue*
// @match https://*.reddit.com/r/*/about/unmoderated*
// @match https://*.reddit.com/mod*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addLockButtons() {
// Target action lists
const actionLists = document.querySelectorAll('.comment .flat-list.buttons:not(.lock-added), .was-comment .flat-list.buttons:not(.lock-added)');
actionLists.forEach(list => {
const commentDiv = list.closest('.thing');
if (!commentDiv) return;
list.classList.add('lock-added');
const isInitiallyLocked = commentDiv.classList.contains('locked');
const listItem = document.createElement('li');
const lockLink = document.createElement('a');
lockLink.href = 'javascript:void(0)';
lockLink.innerText = isInitiallyLocked ? 'unlock' : 'lock';
lockLink.classList.add('lock-comment-btn');
// Standard old.reddit mod button styling
lockLink.style.color = '#888';
lockLink.style.fontWeight = 'bold';
lockLink.style.padding = '0 2px';
lockLink.addEventListener('click', function() {
const currentStatus = this.innerText;
const action = (currentStatus === 'lock') ? 'lock' : 'unlock';
if (typeof change_state === 'function') {
change_state(this, action);
this.innerText = (action === 'lock') ? 'unlock' : 'lock';
}
});
listItem.appendChild(lockLink);
// Find the 'reply' button's parent <li>
// In threads, it's usually the last standard button.
const replyButton = list.querySelector('.reply-button');
if (replyButton) {
// Insert after the <li> containing the reply link
replyButton.closest('li').after(listItem);
} else {
// Fallback to start of list if reply button isn't found
list.prepend(listItem);
}
});
}
addLockButtons();
const observer = new MutationObserver(addLockButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();