Created
September 4, 2024 13:38
-
-
Save Ambushfall/82e9ebcfa94e42ae1a9c8eb50866e58c to your computer and use it in GitHub Desktop.
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
// Menu: Spongebob Mocking! | |
// Description: Copy, run and paste! | |
// Author: Ambushfall | |
// Shortcut: ctrl shift x | |
import '@johnlindquist/kit' | |
const str = await getSelectedText() || await clipboard.readText(); | |
const splitStr = str.split(' ') | |
var newString = '' | |
for (let i = 0; i < splitStr.length; i++) { | |
for (let j = 0; j < splitStr[i].length; j++) { | |
// get last char index | |
const lastIndexOfSplit = splitStr[i].length - 1; | |
// If the index matches the current add space | |
const addTrailingSpace = j == lastIndexOfSplit ? ' ' : '' | |
const char = `${splitStr[i][j]}${addTrailingSpace}` | |
const formatChar = j % 2 == 0 ? char.toLowerCase() : char.toUpperCase() | |
newString += formatChar; | |
} | |
} | |
await clipboard.writeText(newString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment