Nice. You should add element.dispatchEvent(newEvent('input', { bubbles: true })); after you set the value. That tells the interface text was added and enables the buttons under the comment text box. Not a huge issue, but it is odd looking that there is text in the box and buttons do not light up.
I don’t think I will. For me it works perfectly fine as it is right now. Presumably it would also mean that the browser goes “do you really want to leave” any time I’ve gone to a post (since it adds the text to the comment box) which wouldn’t be nice. And also, why would I want to post nothing but my signature? I’m going to be writing something anyways which fires the event.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
There is a problem where if you highlight some text and click reply, the signature will not show up. I even tried making changes to fix it but it didn’t work.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
There is a problem where if you highlight some text and click reply, the signature will not show up. I even tried making changes to fix it but it didn’t work.
Hmm. You could implement a delay. Could be what is happening is that when highlighting and clicking reply, it creates a race condition between whatever inserts the highlighted text into the text box and your sig, which does the same. What likely is happening is that for a split second your sig is added, then it’s replaced by the highlighted text as a quote. If the delay works, you’d want to append to whatever is in there, and it would have to run even if the field value isn’t empty.
Yeah and the very last line turns up a problem, where when you edit a comment it will add another signature. For now I’ll just go with “don’t touch it if it isn’t empty” since it’s all easier.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
Yeah, another solution, though probably also very annoying to implement cleanly, is to have it fire when you click into the textarea and have it check the text for the sig using match or something similar.
Doesn’t add it to the comment box just under the post if you’re opening it from a direct link
I think this is because the mutation observer watches for changes after it’s added, and a direct link loads the page with the comment box directly so it isn’t caught by the observer which is added after the loading is done (whereas loading from the front page doesn’t reload the document and therefore the observer is watching as the comment box is added). Should be fixable if you run the code to find the comment box and add the signature once after adding the mutation observer at the end of your snippet.
Yeah, I was going to suggest that. Probably need to turn that code which adds the sig into a function, that way you can call it after the observer but also inside the observer. Then if you discover any other time you want it to happen (like if the text box is focused and it’s still empty) you can call it again.
Besides your newlines being the wrong way around. This was very helpful! I made this violentmonkey script:
// ==UserScript== // @name hexbear signature // @namespace Violentmonkey Scripts // @match https://hexbear.net/* // @grant none // @version 1.1 // @author Edie // @description 29/12/2025, 18.08.13 // ==/UserScript== var sigHR = "\n\n---\n" var sigMessage = "ⓘ *This user is suspected of being a cat. Please report any suspicious behavior.*" var sig = `${sigHR}${sigMessage}` function addSig(node) { var element = node.querySelector('[id^=markdown-textarea-]') if (element != null) { if (element.value === "") { element.value = sig } } } const observer = new MutationObserver(records => { records.forEach(record => { for (const addedNode of record.addedNodes) { if (addedNode.nodeType == 1) { addSig(addedNode) } } }) }); observer.observe(document.body, { subtree: true, childList: true }); addSig(document)Edit: Updated to version 1.1!
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
Nice. You should add
element.dispatchEvent(new Event('input', { bubbles: true }));after you set the value. That tells the interface text was added and enables the buttons under the comment text box. Not a huge issue, but it is odd looking that there is text in the box and buttons do not light up.I don’t think I will. For me it works perfectly fine as it is right now. Presumably it would also mean that the browser goes “do you really want to leave” any time I’ve gone to a post (since it adds the text to the comment box) which wouldn’t be nice. And also, why would I want to post nothing but my signature? I’m going to be writing something anyways which fires the event.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
Yeah that makes sense actually! I didn’t think of that.
There is a problem where if you highlight some text and click reply, the signature will not show up. I even tried making changes to fix it but it didn’t work.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
Hmm. You could implement a delay. Could be what is happening is that when highlighting and clicking reply, it creates a race condition between whatever inserts the highlighted text into the text box and your sig, which does the same. What likely is happening is that for a split second your sig is added, then it’s replaced by the highlighted text as a quote. If the delay works, you’d want to append to whatever is in there, and it would have to run even if the field value isn’t empty.
Yeah and the very last line turns up a problem, where when you edit a comment it will add another signature. For now I’ll just go with “don’t touch it if it isn’t empty” since it’s all easier.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
Yeah, another solution, though probably also very annoying to implement cleanly, is to have it fire when you click into the textarea and have it check the text for the sig using match or something similar.
I think this is because the mutation observer watches for changes after it’s added, and a direct link loads the page with the comment box directly so it isn’t caught by the observer which is added after the loading is done (whereas loading from the front page doesn’t reload the document and therefore the observer is watching as the comment box is added). Should be fixable if you run the code to find the comment box and add the signature once after adding the mutation observer at the end of your snippet.
Yeah, I was going to suggest that. Probably need to turn that code which adds the sig into a function, that way you can call it after the observer but also inside the observer. Then if you discover any other time you want it to happen (like if the text box is focused and it’s still empty) you can call it again.
Yup. I was thinking to do that.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.
deleted by creator
This is already a userscript.
ⓘ This user is suspected of being a cat. Please report any suspicious behavior.