Skip to content

Instantly share code, notes, and snippets.

@rdodev
Created November 3, 2024 15:20
Show Gist options
  • Select an option

  • Save rdodev/4efa4ff88519b46ed13ba1b4e409f058 to your computer and use it in GitHub Desktop.

Select an option

Save rdodev/4efa4ff88519b46ed13ba1b4e409f058 to your computer and use it in GitHub Desktop.
sPoNgEbOb cAsE bookmarklet
javascript:(function() {
let selection = window.getSelection();
if (selection.toString()) {
const spongebobText = selection.toString()
.split('')
.map((char, index) => index % 2 === 0 ? char.toLowerCase() : char.toUpperCase())
.join('');
document.execCommand('insertText', false, spongebobText);
} else {
alert('pLeAsE SeLeCt sOmE TeXt fIrSt!');
}
})();
// Note that document.execCommand is deprecated and no guarantees it'll keep working in future versions of Chromium-based browsers
// As of: 2024-11-03 is still supported in latest version Chrome, Brave and Edge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment