Skip to content

Instantly share code, notes, and snippets.

@173duprot
Last active September 26, 2024 13:40
Show Gist options
  • Save 173duprot/a86b4780b9a0e0785e066a3e04746a93 to your computer and use it in GitHub Desktop.
Save 173duprot/a86b4780b9a0e0785e066a3e04746a93 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name MNT Community Simple Signature with Observer
// @description Adds a predefined signature to forum posts on https://community.mnt.re
// @version 0.1
// @author 173duprot
// @match https://community.mnt.re/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
const signature = "\n\n---\n\“There’s no forum signatures on this site so I’ll \[do it myself\]\(https://gist.github.com/173duprot/a86b4780b9a0e0785e066a3e04746a93\)\”\n\t- 𝚋⃥̸⃝ 𝚘⃥̸⃝ 𝚡⃥̸⃝ 𝚢⃥̸⃝\n";
const selector = 'textarea.d-editor-input[aria-label*="Type here"]';
const appendSignature = (textarea) => {
if (textarea && !textarea.value.includes(signature)) {
textarea.value += signature;
}
};
// Initial check
appendSignature(document.querySelector(selector));
// Observe future additions to the DOM
const observer = new MutationObserver(() => {
appendSignature(document.querySelector(selector));
});
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment