-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
95 lines (95 loc) · 3.07 KB
/
main.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var In = document.querySelector("#i"),
Out = document.querySelector("#o"),
Exe = document.querySelector("#e");
In.onkeydown = function (event) {
if (event.which == 9) {
event.preventDefault();
var content = this.value,
start = this.selectionStart,
end = this.selectionEnd;
if (start != end) return;
var fContent = content.substr(0, start),
bContent = content.substr(start, content.length);
this.value = fContent + " " + bContent;
this.selectionStart = start + 4;
this.selectionEnd = start + 4;
}
this.oninput && this.oninput();
};
Out.onkeydown = In.onkeydown;
In.oninput = function () {
var content = this.value,
strStart = "",
strTemp = "",
strTabs = "",
enString = "";
for (var i = 0; i < content.length; i++) {
if (content[i].match(/\"|\'/)) {
if (!strStart) {
var j = i - 1;
while (content[j] == " ")
strTabs += content[j--];
strStart = content[i];
} else if (content[i - 1] == "\\" && content[i - 2] != "\\") {
strTemp += content[i];
} else if (content[i] == strStart) {
if (strTemp) {
enString += enFuck(strTemp, strTabs);
strStart = strTemp = strTabs = "";
} else
enString += `${randomO()}+${randomO()}`;
} else {
strTemp += content[i];
}
} else if (strStart) strTemp += content[i];
else enString += content[i];
}
var nums = enString.match(
/(^|\W)(NaN|-NaN|Infinity|-Infinity|\d+.\d+.\d+|-\d+.\d+.\d+|\d+.\d+|-\d+.\d+|-\d+|\d+)/g
);
if (nums)
for (var i = 0; i < nums.length; i++) {
var sym = nums[i].match(/\W/);
sym = sym != null ? sym[0] : "";
if (sym == "$") continue;
enString = enString.replace(nums[i], sym + AB(getNum(nums[i].replace(sym, ""))));
}
var bools = enString.match(/(^|\W)(true|false)/g);
if (bools)
for (var i = 0; i < bools.length; i++) {
var sym = bools[i].match(/\W/);
sym = sym != null ? sym[0] : "";
if (sym == "$") continue;
enString = enString.replace(bools[i], sym + (bools[i].match(/true/) ? "!" : "") + "!" + randomO());
}
Out.value = enString;
};
In.value = `/* example */
(___ => {
___["a"] = 5;
$$_(0, $ => $ < 5)($ => { //for loop
___["a"] += $;
});
_[
"alert"
](___["a"]);
})({});`;
Exe.onclick = () => {
try {
eval(Out.value);
} catch (e) { }
};
document.querySelector("header").onclick = () => location = "index.html";
function enFuck(content, tabs) {
var enContent = "";
try {
content = eval(`"${content}"`);
} catch (err) {
return;
}
for (var i = 0; i < content.length; i++) {
enContent += getChr(content[i]);
if (i < content.length - 1) enContent += "+\n" + tabs;
}
return AB(enContent);
}