forked from aemkei/jsfuck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuck.js
executable file
·38 lines (32 loc) · 927 Bytes
/
fuck.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
#!/usr/bin/env node
var stream = require('stream');
var util = require('util');
var lib = require("./jsfuck.js");
var repl = require('repl');
if(process.argv.length !== 3) {
function Stream() {
stream.Transform.call(this);
}
util.inherits(Stream, stream.Transform);
Stream.prototype._transform = function (chunk, encoding, callback) {
var script = lib.JSFuck.encode(chunk.toString());
var lines = script.split(/\n+/);
for (var i = 0; i < lines.length; i++) {
// ignore empty lines
if (lines[i] !== '') this.push(lines[i] + '\n');
}
callback();
};
var fuckScript = new Stream();
repl.start({
prompt: "FUCK> ",
input: fuckScript,
useColors: true,
output: process.stdout
});
process.stdin.pipe(fuckScript);
} else {
var data = require("fs").readFileSync(process.argv[2], "utf8");
var output = lib.JSFuck.encode(data, false);
console.log(output);
}