CookieClickerHack

Press Alt+G

  1. // ==UserScript==
  2. // @name CookieClickerHack
  3. // @namespace CCH
  4. // @version 0.1
  5. // @description Press Alt+G
  6. // @match http://orteil.dashnet.org/cookieclicker/*
  7. // @grant none
  8. // @include http://orteil.dashnet.org/cookieclicker/*
  9. // ==/UserScript==
  10.  
  11. function base64_decode( data ) { // Decodes data encoded with MIME base64
  12. //
  13. // + original by: Tyler Akins (http://rumkin.com)
  14.  
  15.  
  16. var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  17. var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';
  18.  
  19. do { // unpack four hexets into three octets using index points in b64
  20. h1 = b64.indexOf(data.charAt(i++));
  21. h2 = b64.indexOf(data.charAt(i++));
  22. h3 = b64.indexOf(data.charAt(i++));
  23. h4 = b64.indexOf(data.charAt(i++));
  24.  
  25. bits = h1<<18 | h2<<12 | h3<<6 | h4;
  26.  
  27. o1 = bits>>16 & 0xff;
  28. o2 = bits>>8 & 0xff;
  29. o3 = bits & 0xff;
  30.  
  31. if (h3 == 64) enc += String.fromCharCode(o1);
  32. else if (h4 == 64) enc += String.fromCharCode(o1, o2);
  33. else enc += String.fromCharCode(o1, o2, o3);
  34. } while (i < data.length);
  35.  
  36. return enc;
  37. }
  38.  
  39. function base64_encode( data ) { // Encodes data with MIME base64
  40. //
  41. // + original by: Tyler Akins (http://rumkin.com)
  42. // + improved by: Bayron Guevara
  43.  
  44. var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  45. var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';
  46.  
  47. do { // pack three octets into four hexets
  48. o1 = data.charCodeAt(i++);
  49. o2 = data.charCodeAt(i++);
  50. o3 = data.charCodeAt(i++);
  51.  
  52. bits = o1<<16 | o2<<8 | o3;
  53.  
  54. h1 = bits>>18 & 0x3f;
  55. h2 = bits>>12 & 0x3f;
  56. h3 = bits>>6 & 0x3f;
  57. h4 = bits & 0x3f;
  58.  
  59. // use hexets to index into b64, and append result to encoded string
  60. enc += b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
  61. } while (i < data.length);
  62.  
  63. switch( data.length % 3 ){
  64. case 1:
  65. enc = enc.slice(0, -2) + '==';
  66. break;
  67. case 2:
  68. enc = enc.slice(0, -1) + '=';
  69. break;
  70. }
  71.  
  72. return enc;
  73. }
  74.  
  75.  
  76. function getmorecookie(){
  77. ta=base64_decode(Game.WriteSave(1).replace(/%3D/g,'').replace(/%21END%21/g,''));
  78. ta=ta.replace(/([^\|])\|([\w.e+]+);/,function(a,b,c){
  79. return b+'|'+(Number.MAX_VALUE)+';';
  80. });
  81. ta=base64_encode(ta)+'%21END%21';
  82. Game.LoadSave(ta);
  83. Game.WriteSave();
  84. };
  85. document.addEventListener('keydown',function(e){
  86. if(e.which==71 && e.altKey){
  87. getmorecookie();
  88. }
  89. });