Skip to content

Instantly share code, notes, and snippets.

@GreatPotato
Last active October 9, 2025 15:00
Show Gist options
  • Save GreatPotato/8e6984f1a802fc76e47dbcd2ea2ca495 to your computer and use it in GitHub Desktop.
Save GreatPotato/8e6984f1a802fc76e47dbcd2ea2ca495 to your computer and use it in GitHub Desktop.
UserScript Force Spellcheck
// ==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