SpOnGeBoB cAsE

… when you need to mock people online in style

May 22, 2021 · 1 min read

This one is going to be short.
Spongebob Case, according to KnowYourMeme, consists of an alternation of uppercase and lowercase text, and represents a mocking tone.

I used to do this manually, which was excruciating.

Turns out, it is quite simple with JS, and with some modern browser APIs, totally accessible via a bookmarklet.

spongebobText = text
  .split("")
  .map((c) => (Math.random() < 0.5 ? c.toUpperCase() : c.toLowerCase()))
  .join("");

To add the clipboard functionality, we use navigator.clipboard.writeText

if (navigator.clipboard) {
  let text = "";
  if (window.getSelection) {
    text = window.getSelection().toString();
  } else if (document.selection && document.selection.type != "Control") {
    text = document.selection.createRange().text;
  }

  spongebobText = text
    .split("")
    .map((c) => (Math.random() < 0.5 ? c.toUpperCase() : c.toLowerCase()))
    .join("");

  navigator.clipboard.writeText(spongebobText);
}

Go ahead and install SpOnGeBoB cAsE by dragging it to your bookmarks bar.

Select some text, and click the bookmarklet, and SPOngebOB cAse TexT Will BE coPiED tO YOur CliPboArD 😎.

Feel free to reach out to me via Twitter for any questions/suggestions! 😁

Git and Version Control
Youtube Remaining Time