浏览代码

Optimize numbers inside of MAPPINGs

Alexander I. Zaytsev 11 年之前
父节点
当前提交
ac1c60c5c7
共有 2 个文件被更改,包括 102 次插入88 次删除
  1. 19 5
      jsfuck.js
  2. 83 83
      output.txt

+ 19 - 5
jsfuck.js

@@ -90,7 +90,7 @@
     '*':   USE_CHAR_CODE,
     '+':   '(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[2]',
     ',':   '[[]]["concat"]([[]])+""',
-    '-':   '(+(.0000000001)+"")[2]',
+    '-':   '(+(.+[0000000001])+"")[2]',
     '.':   '(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]',
     '/':   '(false+[+false])["italics"]()[10]',
     ':':   'Function("return Date")()()[21]',
@@ -112,7 +112,7 @@
     '~':   USE_CHAR_CODE
   };
 
-  var GLOBAL = '[]["filter"]["constructor"]("return this")()';
+  var GLOBAL = 'Function("return this")()';
 
   function fillMissingChars(){
     for (var key in MAPPING){
@@ -147,6 +147,20 @@
       );
     }
 
+    function digitReplacer(_,x) { return MAPPING[x]; }
+
+    function numberReplacer(_,y) {
+      var values = y.split("");
+      var head = +(values.shift());
+      var output = "+[]";
+
+      if (head > 0){ output = "+!" + output; }
+      for (i = 1; i < head; i++){ output = "+!+[]" + output; }
+      if (head > 1){ output = output.substr(1); }
+
+      return [output].concat(values).join("+").replace(/(\d)/g, digitReplacer);
+    }
+
     for (i = MIN; i <= MAX; i++){
       character = String.fromCharCode(i);
       value = MAPPING[character];
@@ -161,9 +175,9 @@
         replace(key, SIMPLE[key]);
       }
 
-      for (key = 0; key < 10; key++){
-        replace(key, "+[" + MAPPING[key] + "]");
-      }
+      replace('(\\d\\d+)', numberReplacer);
+      replace('\\((\\d)\\)', digitReplacer);
+      replace('\\[(\\d)\\]', digitReplacer);
 
       replace("GLOBAL", GLOBAL);
       replace('\\+""', "+[]");

+ 83 - 83
output.txt

@@ -1,19 +1,19 @@
-` ` 186
-`!` 8302
-`"` 877
-`#` 8311
-`$` 8316
-`%` 4302
-`&` 8326
-`'` 8331
-`(` 185
-`)` 186
-`*` 8310
-`+` 75
-`,` 626
-`-` 178
+` ` 147
+`!` 6564
+`"` 691
+`#` 6573
+`$` 6578
+`%` 3401
+`&` 6588
+`'` 6593
+`(` 146
+`)` 147
+`*` 6569
+`+` 70
+`,` 498
+`-` 153
 `.` 72
-`/` 383
+`/` 305
 `0` 8
 `1` 10
 `2` 14
@@ -24,71 +24,71 @@
 `7` 39
 `8` 44
 `9` 49
-`:` 6291
-`;` 10511
-`<` 368
-`=` 873
-`>` 374
-`?` 8313
-`@` 8310
-`A` 920
-`B` 923
-`C` 4308
-`D` 4813
-`E` 4314
-`F` 1073
-`G` 6300
-`H` 8346
-`I` 75
-`J` 9210
-`K` 10516
-`L` 8481
-`M` 6301
-`N` 21
-`O` 9238
-`P` 8315
-`Q` 8317
-`R` 8321
-`S` 925
-`T` 6303
-`U` 8336
-`V` 8341
-`W` 8346
-`X` 8351
-`Y` 8356
-`Z` 8325
-`[` 3716
-`\` 8486
-`]` 8332
-`^` 8335
-`_` 8323
-``` 8320
-`a` 20
-`b` 2216
-`c` 181
-`d` 27
-`e` 30
-`f` 18
-`g` 935
-`h` 2238
-`i` 34
-`j` 2242
-`k` 2220
-`l` 24
-`m` 923
-`n` 23
-`o` 182
-`p` 2249
-`q` 2253
-`r` 21
-`s` 29
-`t` 19
-`u` 21
-`v` 2236
-`w` 2245
-`x` 2257
-`y` 91
-`z` 2275
-`{` 190
-`|` 8496
-`}` 8342
+`:` 4970
+`;` 8307
+`<` 292
+`=` 687
+`>` 298
+`?` 6572
+`@` 6572
+`A` 726
+`B` 729
+`C` 3407
+`D` 3802
+`E` 3413
+`F` 847
+`G` 4979
+`H` 6608
+`I` 70
+`J` 7301
+`K` 8312
+`L` 6708
+`M` 4980
+`N` 16
+`O` 7329
+`P` 6577
+`Q` 6579
+`R` 6583
+`S` 731
+`T` 4982
+`U` 6598
+`V` 6603
+`W` 6608
+`X` 6613
+`Y` 6618
+`Z` 6584
+`[` 2931
+`\` 6713
+`]` 6591
+`^` 6594
+`_` 6582
+``` 6582
+`a` 15
+`b` 1748
+`c` 144
+`d` 22
+`e` 25
+`f` 13
+`g` 741
+`h` 1763
+`i` 27
+`j` 1769
+`k` 1752
+`l` 19
+`m` 729
+`n` 18
+`o` 143
+`p` 1774
+`q` 1778
+`r` 16
+`s` 24
+`t` 14
+`u` 16
+`v` 1768
+`w` 1777
+`x` 1782
+`y` 84
+`z` 1807
+`{` 151
+`|` 6723
+`}` 6601