-
-
Save shu8/a1e652178ff4483c5c9d to your computer and use it in GitHub Desktop.
Answer to http://softwarerecs.stackexchange.com/questions/11990/chrome-extension-to-disable-spellcheck-in-a-text-field. Adds a button to stop browser from spellchecking.
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
function addButtonBefore(inputItem) { | |
var button = document.createElement("button"); | |
var text = document.createTextNode("disable/enable spellcheck"); | |
button.appendChild(text); | |
cssString = "font-size: 9px; border: 0; border-radius: 10px; outline: none; color: inherit;" | |
button.style.cssText = cssString; | |
button.setAttribute("title", "disable/enable spellcheck") | |
button.addEventListener('click', function(e) { | |
inputItem.spellcheck = !inputItem.spellcheck; | |
e.preventDefault(); | |
e.stopPropagation(); | |
e.cancelBubble = true; | |
e.returnValue = false; | |
return false; | |
}); | |
inputItem.parentNode.insertBefore(button, inputItem.nextElementSibling); | |
} | |
Array.prototype.forEach.call(document.getElementsByTagName('textarea'), function(inputItem) { | |
addButtonBefore(inputItem); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment