Skip to content

Instantly share code, notes, and snippets.

@Dhravya
Last active January 20, 2023 12:34
Show Gist options
  • Save Dhravya/569eee563066c1919714eaeb6c9c8c8d to your computer and use it in GitHub Desktop.
Save Dhravya/569eee563066c1919714eaeb6c9c8c8d to your computer and use it in GitHub Desktop.
Gist Created in Script Kit
function owofy(text: string, wanky: boolean = false) {
function lastReplace(s: string, old: string, newVal: string): string {
const i = s.lastIndexOf(old);
if (i < 0) {
return s;
}
const start = s.substring(0, i);
const end = s.substring(i + old.length);
return start + newVal + end;
}
function textToOwo(textstr: string): string {
const exclamations = ["?", "!", ".", "*"];
const prefixes = [
"Haii UwU ",
"Hiiiiii 0w0 ",
"Hewoooooo >w< ",
"*W* ",
"mmm~ uwu ",
"Oh... Hi there " + (Math.random() < 0.5 ? "·///·" : "(。O⁄ ⁄ω⁄ ⁄ O。)"),
];
const subs: Record<string, string> = {
why: "wai",
Why: "Wai",
Hey: "Hai",
hey: "hai",
ahw: "ao",
Hi: "Hai",
hi: "hai",
you: "u",
L: "W",
l: "w",
R: "W",
r: "w",
};
textstr = prefixes[Math.floor(Math.random() * prefixes.length)] + textstr;
if (!exclamations.some((e) => textstr.endsWith(e))) {
textstr += " uwu";
}
const smileys = [";;w;;", "^w^", ">w<", "UwU", "(・`ω´・)"];
if (!wanky) {
textstr = textstr.replace("Rank", "Ⓡank").replace("rank", "Ⓡank");
textstr = textstr.replace("Lank", "⒧ank").replace("lank", "⒧ank");
}
textstr = lastReplace(textstr, "there!", "there! *pounces on u*");
for (const key in subs) {
if (subs.hasOwnProperty(key)) {
textstr = textstr.replace(key, subs[key]);
}
}
textstr = lastReplace(
textstr,
"!",
"! " + smileys[Math.floor(Math.random() * smileys.length)]
);
textstr = lastReplace(
textstr,
"?",
"? " + (Math.random() < 0.5 ? "owo" : "O·w·O")
);
textstr = lastReplace(
textstr,
".",
". " + smileys[Math.floor(Math.random() * smileys.length)]
);
const vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"];
if (!wanky) {
textstr = textstr.replace("Ⓡank", "rank").replace("⒧ank", "lank");
}
for (const v of vowels) {
if (textstr.includes(`n${v}`)) {
textstr = textstr.replace(`n${v}`, `ny${v}`);
}
if (textstr.includes(`N${v}`)) {
textstr = textstr.replace(
`N${v}`,
`N${/[A-Z\W]/.test(v) ? "Y" : "y"}${v}`
);
}
}
return textstr;
}
return textToOwo(text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment