-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobf.sh
More file actions
executable file
·29 lines (28 loc) · 747 Bytes
/
Copy pathobf.sh
File metadata and controls
executable file
·29 lines (28 loc) · 747 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
INFILE=${1:-}
OUTMIN=${2:-}
if [ -z "$INFILE" ] || [ -z "$OUTMIN" ]; then
echo "Usage: $0 input.js output.min.js"
exit 1
fi
TRANSFORMED=$(
node - <<'NODE' "$INFILE"
const fs = require('fs');
const infile = process.argv[2];
const src = fs.readFileSync(infile, 'utf8');
global.Az = { value: src };
function encodeAz(){
b=Az.value
a=""
for(i=0;i<b.length;i++)a+=String.fromCharCode(b.charCodeAt(i)+1e3)
Az.value="Л=`"+a+'`;Ж="";for(Й=0;Й<Л.length;Й++)И=Л.charCodeAt(Й),900<И&&(Ж+=String.fromCharCode(И-1e3));eval(Ж)'
}
encodeAz();
process.stdout.write(Az.value);
NODE
)
tmp=$(mktemp --suffix=.js)
printf "%s" "$TRANSFORMED" > "$tmp"
esbuild "$tmp" --minify --outfile="$OUTMIN"
rm -f "$tmp"