Explorar o código

Merge pull request #1 from sugendran/master

Made it work with nodejs
Martin Kleppe %!s(int64=12) %!d(string=hai) anos
pai
achega
cd0b55214d
Modificáronse 2 ficheiros con 13 adicións e 3 borrados
  1. 10 0
      fuck.js
  2. 3 3
      jsfuck.js

+ 10 - 0
fuck.js

@@ -0,0 +1,10 @@
+var lib = require("./jsfuck.js");
+
+if(process.argv.length !== 3) {
+	console.error("Usage: node fuck.js <js file>");
+	return;
+}
+
+var data = require("fs").readFileSync(process.argv[2], "utf8");
+var output = lib.JSFuck.encode(data, false);
+console.log(output);

+ 3 - 3
jsfuck.js

@@ -1,6 +1,6 @@
 /*! JSFuck 1.0 - http://jsfuck.com */
 
-(function(){
+(function(self){
   
   var USE_CHAR_CODE = "USE_CHAR_CODE";
   
@@ -252,7 +252,7 @@
   replaceMap();
   replaceStrings();
   
-  this.JSFuck = {
+  self.JSFuck = {
     encode: encode
   };
-})();
+})(typeof(exports) == "undefined" ? window : exports);