Skip to content

Instantly share code, notes, and snippets.

@davestewart
Created November 9, 2023 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davestewart/7d617d690296e3e09c9bd4e81d389943 to your computer and use it in GitHub Desktop.
Save davestewart/7d617d690296e3e09c9bd4e81d389943 to your computer and use it in GitHub Desktop.
Convert CAPS CASE to Sentence case
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