瀏覽代碼

Merge pull request #1 from sugendran/master

Made it work with nodejs
Martin Kleppe 12 年之前
父節點
當前提交
cd0b55214d
共有 2 個文件被更改,包括 13 次插入3 次删除
  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);