Created
November 9, 2023 13:45
-
-
Save davestewart/7d617d690296e3e09c9bd4e81d389943 to your computer and use it in GitHub Desktop.
Convert CAPS CASE to Sentence case
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
javascript: document.querySelectorAll('*').forEach(e => { | |
if (e.childNodes.length === 1 && e.childNodes[0].nodeType === Element.TEXT_NODE) { | |
if (e.innerText && e.innerText === e.innerText.toUpperCase()) { | |
e.innerText = e.innerText.toLowerCase() | |
.replace(/^\w|\.\s+\w/gm, t => t.toUpperCase()) | |
.replace(/\si\s/, ' I '); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment