JAVASCRIPT   30

evil.js

Guest on 10th October 2021 02:12:33 PM

  1. /* evil.js | http://kitcambridge.be/evil.js | Mike Bannister, Mathias Bynens,
  2.  * Kit Cambridge, Nick Cammarata, Steve De Jonghe, Adam J. Gamble, Devon Govett,
  3.  * Paul Irish, Bradley Meck, Jan Moesen, Alex Sexton, Craig Stuntz,
  4.  * Benjamin Tan, Mike Taylor, Christian Wirkus. */
  5.  
  6. (function() {
  7.   var Shift = [["`", "~"], ["1", "!"], ["2", "@"], ["3", "#"], ["4", "$"],
  8.     ["5", "%"], ["6", "^"], ["7", "&"], ["8", "*"], ["9", "("], ["-", "_"],
  9.     ["=", "+"], ["[", "{"], ["]", "}"], ["\\", "|"], [";", ":"], ["'", "\""],
  10.     [",", "<"], [".", ">"], ["/", "?"]];
  11.  
  12.   var Object = this.Object,
  13.       Math = this.Math,
  14.       String = this.String,
  15.       reverse = Shift.reverse,
  16.       slice = Shift.slice,
  17.       getClass = Math.toString,
  18.       hasOwn = Math.hasOwnProperty,
  19.       toUpperCase = "".toUpperCase,
  20.       fromCharCode = String.fromCharCode;
  21.  
  22.   var nativeFnToStringResult = String(getClass)
  23.         .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1 ');
  24.  
  25.   var random = Math.random,
  26.       round = Math.round,
  27.       document = this.document,
  28.       write = document && document.write,
  29.       location = this.location,
  30.       search = location && location.search,
  31.       alert = this.alert,
  32.       confirm = this.confirm;
  33.  
  34.   var PrimitiveType = /^(?:undefined|number|boolean|string)$/,
  35.       isModern = document && "querySelectorAll" in document &&
  36.                  !PrimitiveType.test(typeof document.querySelectorAll) &&
  37.                  "addEventListener" in document &&
  38.                  !PrimitiveType.test(typeof document.addEventListener);
  39.  
  40.   var Invert = [["\u0021", "\u00a1"], ["\u0022", "\u201e"], ["\u0026", "\u214b"],
  41.     ["\u0027", "\u002c"], ["\u0028", "\u0029"], ["\u002e", "\u02d9"],
  42.     ["\u0033", "\u0190"], ["\u0034", "\u152d"], ["\u0036", "\u0039"],
  43.     ["\u0037", "\u2c62"], ["\u003b", "\u061b"], ["\u003c", "\u003e"],
  44.     ["\u003f", "\u00bf"], ["\u0041", "\u2200"], ["\u0042", "\u1012"],
  45.     ["\u0043", "\u2183"], ["\u0044", "\u25d6"], ["\u0045", "\u018e"],
  46.     ["\u0046", "\u2132"], ["\u0047", "\u2141"], ["\u004a", "\u017f"],
  47.     ["\u004b", "\u22ca"], ["\u004c", "\u2142"], ["\u004d", "\u0057"],
  48.     ["\u004e", "\u1d0e"], ["\u0050", "\u0500"], ["\u0051", "\u038c"],
  49.     ["\u0052", "\u1d1a"], ["\u0054", "\u22a5"], ["\u0055", "\u2229"],
  50.     ["\u0056", "\u1d27"], ["\u0059", "\u2144"], ["\u005b", "\u005d"],
  51.     ["\u005f", "\u203e"], ["\u0061", "\u0250"], ["\u0062", "\u0071"],
  52.     ["\u0063", "\u0254"], ["\u0064", "\u0070"], ["\u0065", "\u01dd"],
  53.     ["\u0066", "\u025f"], ["\u0067", "\u0183"], ["\u0068", "\u0265"],
  54.     ["\u0069", "\u0131"], ["\u006a", "\u027e"], ["\u006b", "\u029e"],
  55.     ["\u006c", "\u0283"], ["\u006d", "\u026f"], ["\u006e", "\u0075"],
  56.     ["\u0072", "\u0279"], ["\u0074", "\u0287"], ["\u0076", "\u028c"],
  57.     ["\u0077", "\u028d"], ["\u0079", "\u028e"], ["\u007b", "\u007d"],
  58.     ["\u203f", "\u2040"], ["\u2045", "\u2046"], ["\u2234", "\u2235"]];
  59.  
  60.   var invert = function(value) {
  61.     var results = "", length, size, character;
  62.     for (length = value.length; length--;) {
  63.       character = value.charAt(length);
  64.       for (size = Invert.length; size--;) {
  65.         if (Invert[size][0] == character) {
  66.           character = Invert[size][1];
  67.           break;
  68.         }
  69.       }
  70.       results += character;
  71.     }
  72.     return results;
  73.   };
  74.  
  75.   if (typeof hasOwn != "function") {
  76.     hasOwn = function() {
  77.       return !round(random());
  78.     };
  79.   }
  80.  
  81.   var XMLHttpRequest = this.XMLHttpRequest = function() {
  82.     this.readyState = Infinity;
  83.   };
  84.  
  85.   XMLHttpRequest.prototype.open = XMLHttpRequest.prototype.send = function() {};
  86.  
  87.   this.undefined = this.NaN = 1 / 0;
  88.   this.Infinity = "\u221e";
  89.  
  90.   this.alert = function(value) {
  91.     alert(invert(value));
  92.   };
  93.  
  94.   this.confirm = function(value) {
  95.     confirm(invert(value));
  96.   };
  97.  
  98.   this.prompt = this.open;
  99.  
  100.   this.isNaN = function(value) {
  101.     return true;
  102.   };
  103.  
  104.   if (typeof search == "string") {
  105.     try {
  106.       eval(decodeURIComponent(search.replace("?", "")));
  107.     } catch (e) {
  108.       // Ignore errors.
  109.     }
  110.   }
  111.  
  112.   if (document && write) {
  113.     document.write = function(element) {
  114.       element = "<marquee><blink>" + element + "</blink></marquee>";
  115.       write.call(document, element);
  116.       write.call(document, element);
  117.     };
  118.   }
  119.  
  120.   Math.ceil = function() {
  121.     return 42;
  122.   };
  123.  
  124.   Math.max = Math.min;
  125.   Math.min = function() {
  126.     return Infinity;
  127.   };
  128.  
  129.   Math.pow = function() {
  130.     return "pow pow pow!";
  131.   };
  132.  
  133.   Math.random = function() {
  134.     return fromCharCode(~~(random() * 1e3));
  135.   };
  136.  
  137.   Math.round = Math.sqrt;
  138.   Math.SQRT2 = Math.SQRT1_2;
  139.   Math.SQRT1_2 = Math.LOG2E;
  140.   Math.LOG2E = Math.LN10;
  141.   Math.LN10 = Math.LN2;
  142.   Math.LN2 = Math.E;
  143.   Math.E = Math.PI;
  144.   Math.PI = 3.2;
  145.  
  146.   Array.prototype.reverse = function() {
  147.     for (var length = this.length, element; length--;) {
  148.       element = this[length];
  149.       this[length] = typeof element == "string" ? reverse.call(element.split("")).join("") : (element * random());
  150.     }
  151.     return reverse.call(this);
  152.   };
  153.  
  154.   Array.prototype.sort = function() {
  155.     for (var index, element, length = this.length; length;) {
  156.       index = ~~(random() * length);
  157.       element = this[--length];
  158.       this[length] = this[index];
  159.       this[index] = element;
  160.     }
  161.     return this;
  162.   };
  163.  
  164.   String.prototype.toUpperCase = function() {
  165.     var value = toUpperCase.call(this).split(""), length, size, pair;
  166.     for (length = value.length; length--;) {
  167.       for (size = Shift.length; size--;) {
  168.         pair = Shift[size];
  169.         if (pair[0] == value[length]) {
  170.           value[length] = pair[1];
  171.         }
  172.       }
  173.     }
  174.     return value.join("").replace(/([A-Z])/g, "$1\u0305");
  175.   };
  176.  
  177.   String.prototype.trim = String.prototype.trimLeft = String.prototype.trimRight = function() {
  178.     return "";
  179.   };
  180.  
  181.   Object.create = Object.defineProperty = Object.getPrototypeOf = function() {
  182.     return {};
  183.   };
  184.  
  185.   Object.keys = function() {
  186.     return [];
  187.   };
  188.  
  189.   Object.prototype.hasOwnProperty = function(prop) {
  190.     return !hasOwn.call(this, prop);
  191.   };
  192.  
  193.   Object.prototype.toString = function() {
  194.     return "[object Object]";
  195.   };
  196.  
  197.   Function.prototype.toString = function() {
  198.     return nativeFnToStringResult;
  199.   };
  200.  
  201.   if (isModern) {
  202.     var changePlaybackRate = function() {
  203.       var videos = document.querySelectorAll('video');
  204.       for (var index = -1, video; video = videos[++index];) {
  205.         var sign = random() > 0.5 ? 1 : -1;
  206.         video.playbackRate = 1 + sign * (0.1 + random() * 0.1);
  207.       }
  208.     };
  209.  
  210.     document.addEventListener('DOMContentLoaded', changePlaybackRate, false);
  211.     if (document.readyState === 'complete') {
  212.       changePlaybackRate();
  213.     }
  214.   }
  215.  
  216.   if (typeof jQuery == "function") {
  217.     jQuery.ajaxSetup({
  218.       "async": false
  219.     });
  220.   }
  221.  
  222.   this.JSON = {
  223.     "parse": function() {
  224.       return {};
  225.     },
  226.     "stringify": function(value) {
  227.       return getClass.call(value);
  228.     }
  229.   };
  230. }).call(this);

Raw Paste


Login or Register to edit or fork this paste. It's free.