Created
November 3, 2024 15:20
-
-
Save rdodev/4efa4ff88519b46ed13ba1b4e409f058 to your computer and use it in GitHub Desktop.
sPoNgEbOb cAsE bookmarklet
This file contains hidden or 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:(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