<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Obfuscator JavaScript Tool</title>
<style>
h1 {
text-align:center;
font-family:Calibri Light;
font-size:36px;
background-image: linear-gradient(to right, black,#CCC 20% 80%,black);
border-radius:8px;
}
</style>
<script>
// slice(start, end)
// substring(start, end)
// substr(start, length)
// remove //
function removeLineComment(line)
{
epos = line.indexOf('//');
if (epos != -1) {
return line.substring(0,epos);
} else return line;
}
// remove /* */
function removeMultiComment(s)
{
spos = s.indexOf("/*");
if (spos != -1 ) {
lpos = s.substring(2).indexOf("*/");
if (lpos == -1) {
alert(" */ not found to: "+s.substr(0,spos+2));
return s.substring(spos+2);
}
if (s.length >= lpos+4) // there are more chars after the */
s = s.substr(0,spos)+s.substring(lpos+4);
else
s = s.substr(0,spos);
}
return s;
}
/* replcae a text area with \t \n // /* */
function removeComments()
{
str = document.getElementById("source").value;
while (str.indexOf("/*") >=0 ) {
str = removeMultiComment(str);
}
str = str.trim();
lines = str.split('\n');
for (i=0 ; i < lines.length ; i++ ) {
lines[i] = removeLineComment(lines[i]);
}
str = lines.join("");
str = str.replace(/(\r\n|\n|\r)/gm, '');
str = str.replace(/\t/g, ' ');
for (b=0; b<10 ; b++) str = str.replace(/ /g, ' ');
document.getElementById("target").value = str;
}
</script>
</head>
<body>
<h1>Obfuscator tool for JavaScript</h1>
<div align="center">
<table style="width: 80%" cellpadding="10" cellspacing="10">
<tr>
<td>
<textarea id="source" style="width:100%; height:60vh" placeholder="Enter your sources here"></textarea></td>
<td style="width:100px; background-color: #CCCCCC; cursor:pointer;text-align:center; border-radius:20px;" onclick="removeComments()">
Obfuscator</td>
<td><textarea id="target" style="width:100%; height:60vh"></textarea></td>
</tr>
</table>
</div>
</body>
</html>