index.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <html>
  2. <head>
  3. <title>JSFuck - Write any JavaScript with 6 Characters: []()!+</title>
  4. <meta name="description" content="JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters execute code.">
  5. <meta property="og:image" content="http://www.jsfuck.com/preview.png" />
  6. <meta name="viewport" content="width=device-width" />
  7. <style>
  8. body {
  9. padding: 20px;
  10. }
  11. body, * {
  12. font-family: monospace;
  13. font-size: 14px;
  14. line-height: 1.4em;
  15. }
  16. h1 {
  17. font-size: 2em;
  18. position: absolute;
  19. top: 70px;
  20. font-weight: normal;
  21. left: 140px;
  22. }
  23. h2 {
  24. width: 90px;
  25. text-align: right;
  26. padding: 50px 5px 5px;
  27. background: #F0DB4E;
  28. color: #323230;
  29. font-weight: bold;
  30. font-size: 20px;
  31. line-height: 1em;
  32. }
  33. h3 {
  34. font-weight: bold;
  35. }
  36. p, li, textarea, .actions {
  37. width: 100%;
  38. max-width: 600px;
  39. }
  40. textarea {
  41. display: block;
  42. height: 200px;
  43. margin: 1em 0;
  44. }
  45. ul.pre li{
  46. white-space: pre;
  47. }
  48. .checkbox {
  49. display: inline-block;
  50. }
  51. .actions a {
  52. float: right;
  53. }
  54. .actions {
  55. clear: both;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <h1>JSFuck</h1>
  61. <h2>()+<br>[]!</h2>
  62. <p>JSFuck is an esoteric and educational programming style based on the
  63. atomic parts of JavaScript. It uses only six different characters to
  64. write and execute code.</p>
  65. <p>It does not depend on a browser, so you can even run it on Node.js.</p>
  66. <p>Use the form below to convert your own script. Uncheck "eval source" to
  67. get back a plain string.</p>
  68. <input id="input" type="text" value="alert(1)"/>
  69. <button id="encode" type="text">Encode</button>
  70. <div class="checkbox">
  71. <input id="eval" type="checkbox" checked />
  72. <label for="eval">Eval Source</label>
  73. </div>
  74. <textarea id="output"></textarea>
  75. <div class="actions">
  76. <span id="stats"></span>
  77. <a id="run" href="#">Run This</a>
  78. </div>
  79. <h3>Links</h3>
  80. <ul>
  81. <li>View source on <a href="http://github.com/aemkei/jsfuck">GitHub</a></li>
  82. <li>Follow <a href="http://twitter.com/aemkei">@aemkei</a> (Martin Kleppe)</li>
  83. <li>Original discussion at <a href="http://sla.ckers.org/forum/read.php?24,32930">Sla.ckers.org</a></li>
  84. <li>Alternatives: <a href="http://patriciopalladino.com/files/hieroglyphy/">Hieroglyphy</a> (8 chars), <a href="http://utf-8.jp/public/jsfuck.html">utf-8.jp</a> (broken)</li>
  85. </ul>
  86. <h3>Basics</h3>
  87. <ul class="pre">
  88. <li>false => ![]</li>
  89. <li>true => !![]</li>
  90. <li>undefined => [][[]]</li>
  91. <li>NaN => +[![]]</li>
  92. <li>0 => +[]</li>
  93. <li>1 => +!+[]</li>
  94. <li>2 => !+[]+!+[]</li>
  95. <li>10 => [+!+[]]+[+[]]</li>
  96. <li>Array => []</li>
  97. <li>Number => +[]</li>
  98. <li>String => []+[]</li>
  99. <li>Boolean => ![]</li>
  100. <li>Function => []["sort"]</li>
  101. <li>eval => []["sort"]["constructor"]( CODE )()</li>
  102. <li>window => []["sort"]["constructor"]("return this")()</li>
  103. </ul>
  104. <p>See the full list <a href="https://github.com/aemkei/jsfuck/blob/master/jsfuck.js">here</a>.</p>
  105. <script src="jsfuck.js"></script>
  106. <script>
  107. function $(id){
  108. return document.getElementById(id);
  109. }
  110. function encode(){
  111. var output = JSFuck.encode($("input").value, $("eval").checked);
  112. $("output").value = output;
  113. $("stats").innerHTML = output.length + " chars";
  114. }
  115. $("encode").onclick = encode;
  116. $("eval").onchange = encode;
  117. encode();
  118. $("run").onclick = function(){
  119. value = eval($("output").value);
  120. if (!$("eval").checked){
  121. alert('"' + value + '"');
  122. }
  123. return false;
  124. };
  125. </script>
  126. <script type="text/javascript">
  127. var _gaq = _gaq || [];
  128. _gaq.push(['_setAccount', 'UA-57649-11']);
  129. _gaq.push(['_trackPageview']);
  130. (function() {
  131. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  132. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  133. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  134. })();
  135. </script>
  136. </body>
  137. </html>