Last active
September 26, 2024 13:40
-
-
Save 173duprot/a86b4780b9a0e0785e066a3e04746a93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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