-
Notifications
You must be signed in to change notification settings - Fork 0
/
inject.js
74 lines (66 loc) · 2.3 KB
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var faces = [`(・\`ω´・)`, `;;w;;`, `owo`, `UwU`, `>w<`, `^w^`, `ÚwÚ`, `:3`, `x3`];
var actions = [
`*blushes*`,
`*whispers to self*`,
`*sweats*`,
`*sees bulge*`,
`*runs away*`,
`*huggles tightly*`,
`*boops your nose*`,
`*starts twerking*`,
];
var exclamations = [`?!!`, `?!?1`, `!!11`, `?!?!`, `!?`];
function getElement(array) {
return array[Math.floor(Math.random() * array.length)];
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function uwufyWord(word) {
// Check if the word is suitable for adding a face or action
if (word.length > 3 && word.length <= 6 && !/[.,?!]+$/.test(word)) {
if (Math.random() < 0.5) {
// Add a face
return word + " " + getElement(faces);
} else {
// Add an action
return word + " " + getElement(actions);
}
} else {
// Regular uwufication
word = word.replace(/(?:r|l)/g, `w`);
word = word.replace(/(?:R|L)/g, `W`);
word = word.replace(/n([aeiou])/g, `ny$1`);
word = word.replace(/N([aeiou])/g, `Ny$1`);
word = word.replace(/N([AEIOU])/g, `Ny$1`);
word = word.replace(/ove/g, `uv`);
word = word.replace(/uwu/g, faces[Math.floor(Math.random() * (5)) + 2]);
return word;
}
}
function uwufySentence(sentence) {
sentence = sentence.replace(/[?!]+$/, getElement(exclamations));
var words = sentence.split(/\s+/);
var urlPattern = new RegExp(/(?:https?|ftp):\/\/[\n\S]+/g);
let uwufied = ``;
words.forEach((word) => {
uwufied += ` ${urlPattern.test(word) ? word : uwufyWord(word)}`;
});
return uwufied.trim();
}
// Get a random uwu face
function uwuFace() {
return faces[Math.floor(Math.random() * faces.length)];
}
var activeElement = document.activeElement;
if (
activeElement.tagName === 'INPUT' ||
activeElement.tagName === 'TEXTAREA' ||
activeElement.className == 'markup_a7e664 editor__66464 slateTextArea__0661c fontSize16Padding__48818'
) {
var selectedText = document.activeElement.children[0].children[0].children[0].children[0].innerHTML;
var convertedText = uwufySentence(selectedText);
navigator.clipboard.writeText(convertedText);
}