Last active
October 9, 2025 15:00
-
-
Save GreatPotato/8e6984f1a802fc76e47dbcd2ea2ca495 to your computer and use it in GitHub Desktop.
UserScript Force Spellcheck
This file contains hidden or 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 Force Spellcheck | |
| // @namespace https://example.com/ | |
| // @version 1.0 | |
| // @description Force spellcheck = true on all textareas / inputs / contenteditable | |
| // @match *://*/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| "use strict"; | |
| function fix(el) { | |
| if (!el) return; | |
| // Only if element supports spellcheck | |
| if ("spellcheck" in el) { | |
| // set the property and attribute | |
| el.spellcheck = true; | |
| el.setAttribute("spellcheck", "true"); | |
| } | |
| } | |
| function scanAll() { | |
| document.querySelectorAll('textarea, input, [contenteditable="true"]').forEach(fix); | |
| } | |
| // Initial pass | |
| scanAll(); | |
| // Also do it on focus (some sites re-add or override) | |
| document.addEventListener("focusin", (ev) => { | |
| fix(ev.target); | |
| }); | |
| // Observe dynamically added elements | |
| const mo = new MutationObserver((muts) => { | |
| for (const m of muts) { | |
| for (const node of m.addedNodes) { | |
| if (node.nodeType === Node.ELEMENT_NODE) { | |
| if (node.matches && node.matches('textarea, input, [contenteditable="true"]')) { | |
| fix(node); | |
| } | |
| node.querySelectorAll && node.querySelectorAll('textarea, input, [contenteditable="true"]').forEach(fix); | |
| } | |
| } | |
| } | |
| }); | |
| mo.observe(document.documentElement, { childList: true, subtree: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment