Chrome Dino Hacks

Saves Data, Invincibility Toggle, More To Come! Esc To Show/Hide Cheats

  1. // ==UserScript==
  2. // @name Chrome Dino Hacks
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Saves Data, Invincibility Toggle, More To Come! Esc To Show/Hide Cheats
  6. // @author You
  7. // @match https://chromedino.com/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Your code here...
  16. })();
  17. checkCookie();
  18. window.original = Runner.prototype.gameOver
  19. var cheats = `<label class="switch" id="cheats" onclick="setTimeout(()=>{ if (document.getElementById('invincible').checked == true){ Runner.prototype.gameOver = function (){}; } else { Runner.prototype.gameOver = original; }}, 100)">
  20. <input type="checkbox" id="invincible">
  21. <span class="slider round">Invincible</span>
  22. </label>
  23. <style>/* The switch - the box around the slider */
  24. .switch {
  25. position: relative;
  26. display: inline-block;
  27. width: 60px;
  28. height: 34px;
  29. }
  30.  
  31. /* Hide default HTML checkbox */
  32. .switch input {
  33. opacity: 0;
  34. width: 0;
  35. height: 0;
  36. }
  37.  
  38. /* The slider */
  39. .slider {
  40. position: absolute;
  41. cursor: pointer;
  42. top: 0;
  43. left: 0;
  44. right: 0;
  45. bottom: 0;
  46. background-color: #ccc;
  47. -webkit-transition: .4s;
  48. transition: .4s;
  49. }
  50.  
  51. .slider:before {
  52. position: absolute;
  53. content: "";
  54. height: 26px;
  55. width: 26px;
  56. left: 4px;
  57. bottom: 4px;
  58. background-color: white;
  59. -webkit-transition: .4s;
  60. transition: .4s;
  61. }
  62.  
  63. input:checked + .slider {
  64. background-color: #2196F3;
  65. }
  66.  
  67. input:focus + .slider {
  68. box-shadow: 0 0 1px #2196F3;
  69. }
  70.  
  71. input:checked + .slider:before {
  72. -webkit-transform: translateX(26px);
  73. -ms-transform: translateX(26px);
  74. transform: translateX(26px);
  75. }
  76.  
  77. /* Rounded sliders */
  78. .slider.round {
  79. border-radius: 34px;
  80. }
  81.  
  82. .slider.round:before {
  83. border-radius: 50%;
  84. }</style>`
  85.  
  86. var sts = document.createElement("DIV");
  87. sts.innerHTML = cheats;
  88. sts.setAttribute("class", "flex-around key-category-box")
  89. sts.style = "margin-top:10px;"
  90. document.getElementById("main-frame-error").appendChild(sts)
  91.  
  92. function setCookie(cname, cvalue, exdays) {
  93. const d = new Date();
  94. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  95. let expires = "expires="+d.toUTCString();
  96. document.cookie = cname + "=" + cvalue + ";" + expires;
  97. }
  98.  
  99. function getCookie(cname) {
  100. let name = cname + "=";
  101. let ca = document.cookie.split(';');
  102. for(let i = 0; i < ca.length; i++) {
  103. let c = ca[i];
  104. while (c.charAt(0) == ' ') {
  105. c = c.substring(1);
  106. }
  107. if (c.indexOf(name) == 0) {
  108. return c.substring(name.length, c.length);
  109. }
  110. }
  111. return "";
  112. }
  113.  
  114. function toggleCookie(cname) {
  115. setCookie(cname, 1 - getCookie(cname), 365);
  116. }
  117.  
  118. function checkCookie() {
  119. let user = getCookie("High Score");
  120. if (user != "" && user != undefined) {
  121. Runner.instance_.distanceMeter.highScore = JSON.parse(getCookie("High Score"));
  122. } else {
  123. setCookie("High Score", "['10', '11', '', '0', '0', '0', '4', '6']", 365);
  124. }
  125. let user2 = getCookie("Highest Score");
  126. if (user2 != "" && user2 != undefined) {
  127. Runner.instance_.highestScore = getCookie("Highest Score")
  128. } else {
  129. setCookie("Highest Score", Runner.instance_.highestScore, 365);
  130. }
  131. let user22 = getCookie("showcheats");
  132. if (user22 != "" && user22 != undefined) {
  133. } else {
  134. setCookie("showcheats", 0, 365);
  135. }
  136. }
  137.  
  138. document.addEventListener("keydown", (e) => {
  139. if (e.key == "Escape") {
  140. toggleCookie("showcheats")
  141. }
  142. });
  143.  
  144. setInterval(()=>{
  145. if(Runner.instance_.distanceMeter.highScore !== undefined && Runner.instance_.distanceMeter.highScore !== null) {if(getCookie("High Score") !== Runner.instance_.distanceMeter.highScore) {
  146. var json_str = JSON.stringify(Runner.instance_.distanceMeter.highScore);
  147. setCookie("High Score", json_str, 365);
  148. }
  149. }
  150. if(getCookie("Highest Score") !== Runner.instance_.highestScore) {
  151. setCookie("Highest Score", Runner.instance_.highestScore, 365);
  152. }
  153. if(getCookie("showcheats") == 1) {
  154. document.getElementById("cheats").setAttribute("style", "display: none;");
  155. } else { document.getElementById("cheats").setAttribute("style", ""); };
  156.  
  157. }, 100);