瀏覽代碼

Find and replace missing chars.

Martin Kleppe 12 年之前
父節點
當前提交
832827c71b
共有 1 個文件被更改,包括 40 次插入2 次删除
  1. 40 2
      jsfuck.js

+ 40 - 2
jsfuck.js

@@ -166,9 +166,9 @@
       replace("GLOBAL", GLOBAL);
       replace('\\+""', "+[]");
       replace('""', "[]+[]");
-      
+            
       try {
-        eval(value);
+        // eval(value);
       } catch (e) {
         throw "Can't convert " + character + "\n" + original + "\n" + value;
       }
@@ -176,6 +176,41 @@
       MAPPING[character] = value;
     }
   }
+  
+  function replaceStrings(){
+    
+    var regEx = /[^\[\]\(\)\!\+]{1}/g,
+      all, value, missing;
+    
+    function findMissing(){
+      var all, value;
+      missing = {};
+      for (all in MAPPING){
+        value = MAPPING[all];
+        if (regEx.test(value)){
+          missing[all] = value;
+        }
+      }
+    }
+    
+    for (all in MAPPING){
+      value = MAPPING[all].replace(/\"/g, "");
+      MAPPING[all] = value;
+      console.log(all, value);
+    }
+    
+    findMissing();
+    
+    for (all in missing){
+      missing[all] =  MAPPING[all].replace(regEx, function(c){ 
+        return missing[c] ? c : MAPPING[c];
+      });
+      
+    }
+    
+    console.log(missing);
+    
+  }
 
   function swap(input, recursive){
     
@@ -222,8 +257,11 @@
   fillMissingDigits();
   fillMissingChars();
   replaceMap();
+  replaceStrings();
+  
   
   
+  return
   
   var input = "true\"false\"InfinityundefinedNaNalert(1);";
   for (var i = MIN; i <= MAX; i++){