Heart Clicker Game Cheat GUI

Add a mini cheat GUI to the Heart Clicker Game, make it draggable, and ensure all cheats work

  1. // ==UserScript==
  2. // @name Heart Clicker Game Cheat GUI
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Add a mini cheat GUI to the Heart Clicker Game, make it draggable, and ensure all cheats work
  6. // @match https://heart-io.github.io/Heart/
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. // Create and apply styles
  14. const style = document.createElement('style');
  15. style.textContent = `
  16. #cheat-gui {
  17. position: fixed;
  18. top: 10px;
  19. right: 10px;
  20. background: rgba(0, 0, 0, 0.8);
  21. color: #fff;
  22. padding: 10px;
  23. border-radius: 10px;
  24. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  25. z-index: 1000;
  26. cursor: move;
  27. }
  28. #cheat-gui button, #cheat-gui input, #cheat-gui select {
  29. margin: 5px 0;
  30. padding: 5px;
  31. font-size: 14px;
  32. border-radius: 5px;
  33. border: 1px solid #ccc;
  34. }
  35. #cheat-gui button {
  36. background-color: #3498db;
  37. color: #fff;
  38. border: none;
  39. cursor: pointer;
  40. transition: background 0.2s ease-in-out;
  41. }
  42. #cheat-gui button:hover {
  43. background-color: #2980b9;
  44. }
  45. `;
  46. document.head.appendChild(style);
  47.  
  48. // Create and add cheat GUI
  49. const cheatGui = document.createElement('div');
  50. cheatGui.id = 'cheat-gui';
  51. document.body.appendChild(cheatGui);
  52.  
  53. const cheatTitle = document.createElement('h2');
  54. cheatTitle.innerText = 'Cheat Console';
  55. cheatGui.appendChild(cheatTitle);
  56.  
  57. const setHeartInput = document.createElement('input');
  58. setHeartInput.id = 'set-heart-input';
  59. setHeartInput.placeholder = 'Enter heart amount';
  60. setHeartInput.type = 'number';
  61. cheatGui.appendChild(setHeartInput);
  62.  
  63. const setHeartButton = document.createElement('button');
  64. setHeartButton.id = 'set-heart-button';
  65. setHeartButton.innerText = 'Set Hearts';
  66. cheatGui.appendChild(setHeartButton);
  67.  
  68. const characterSelect = document.createElement('select');
  69. characterSelect.id = 'character-select';
  70. const heartOptions = ['❤️', '💙', '💚', '💛', '💜']; // Modify as needed
  71. heartOptions.forEach(char => {
  72. const option = document.createElement('option');
  73. option.value = char;
  74. option.innerText = char;
  75. characterSelect.appendChild(option);
  76. });
  77. cheatGui.appendChild(characterSelect);
  78.  
  79. const setCharacterButton = document.createElement('button');
  80. setCharacterButton.id = 'set-character-button';
  81. setCharacterButton.innerText = 'Change Character';
  82. cheatGui.appendChild(setCharacterButton);
  83.  
  84. const buyAnyUpgradeButton = document.createElement('button');
  85. buyAnyUpgradeButton.id = 'buy-any-upgrade-button';
  86. buyAnyUpgradeButton.innerText = 'Buy Any Upgrade';
  87. cheatGui.appendChild(buyAnyUpgradeButton);
  88.  
  89. // Add additional cheats
  90. function addCheatButton(buttonId, buttonText, onClick) {
  91. const button = document.createElement('button');
  92. button.id = buttonId;
  93. button.innerText = buttonText;
  94. button.addEventListener('click', onClick);
  95. cheatGui.appendChild(button);
  96. }
  97.  
  98. // Draggable functionality
  99. function makeDraggable(element) {
  100. let isDragging = false;
  101. let offsetX = 0;
  102. let offsetY = 0;
  103.  
  104. element.addEventListener('mousedown', (e) => {
  105. isDragging = true;
  106. offsetX = e.clientX - element.getBoundingClientRect().left;
  107. offsetY = e.clientY - element.getBoundingClientRect().top;
  108. document.addEventListener('mousemove', onMouseMove);
  109. document.addEventListener('mouseup', onMouseUp);
  110. });
  111.  
  112. function onMouseMove(e) {
  113. if (isDragging) {
  114. const x = e.clientX - offsetX;
  115. const y = e.clientY - offsetY;
  116. element.style.left = `${x}px`;
  117. element.style.top = `${y}px`;
  118. }
  119. }
  120.  
  121. function onMouseUp() {
  122. isDragging = false;
  123. document.removeEventListener('mousemove', onMouseMove);
  124. document.removeEventListener('mouseup', onMouseUp);
  125. }
  126. }
  127.  
  128. makeDraggable(cheatGui);
  129.  
  130. // Game state variables
  131. let heartCount = 0;
  132. let currentHeart = '❤️';
  133.  
  134. // Update heart count display
  135. function updateHeartCount() {
  136. const heartCountElement = document.getElementById('heart-count');
  137. if (heartCountElement) {
  138. heartCountElement.innerText = heartCount;
  139. }
  140. }
  141.  
  142. // Change heart character
  143. function changeHeartCharacter(newHeart) {
  144. currentHeart = newHeart;
  145. const clicker = document.getElementById('clicker');
  146. if (clicker) {
  147. clicker.innerText = currentHeart;
  148. }
  149. }
  150.  
  151. // Apply upgrades
  152. function applyUpgrade() {
  153. const upgrades = document.querySelectorAll('#shop button[id^="buy-upgrade"]');
  154. upgrades.forEach(button => {
  155. const cost = parseInt(button.innerText.replace('Cost: ', '').replace(' Hearts', ''));
  156. if (heartCount >= cost) {
  157. heartCount -= cost;
  158. button.innerText = 'Purchased'; // Mark upgrade as purchased
  159. // Implement specific upgrade logic here
  160. }
  161. });
  162. updateHeartCount();
  163. }
  164.  
  165. // Event handlers
  166. document.getElementById('set-heart-button').addEventListener('click', () => {
  167. const heartAmount = parseInt(document.getElementById('set-heart-input').value);
  168. if (!isNaN(heartAmount)) {
  169. heartCount = heartAmount;
  170. updateHeartCount();
  171. }
  172. });
  173.  
  174. document.getElementById('set-character-button').addEventListener('click', () => {
  175. const selectedCharacter = document.getElementById('character-select').value;
  176. if (selectedCharacter) {
  177. changeHeartCharacter(selectedCharacter);
  178. }
  179. });
  180.  
  181. document.getElementById('buy-any-upgrade-button').addEventListener('click', applyUpgrade);
  182.  
  183. // Add cheat buttons with functionalities
  184. addCheatButton('cheat1', 'Unlock All Upgrades', () => {
  185. document.querySelectorAll('#shop button[id^="buy-upgrade"]').forEach(button => {
  186. button.innerText = 'Purchased'; // Mark as purchased
  187. });
  188. });
  189. addCheatButton('cheat2', 'Add 10,000 Hearts', () => { heartCount += 10000; updateHeartCount(); });
  190. addCheatButton('cheat3', 'Set Hearts to Max', () => { heartCount = Number.MAX_SAFE_INTEGER; updateHeartCount(); });
  191. addCheatButton('cheat4', 'Enable Double Clicks', () => alert('Double clicks enabled!'));
  192. addCheatButton('cheat5', 'Disable Click Limit', () => alert('Click limit disabled!'));
  193. addCheatButton('cheat6', 'Reset Game Progress', () => alert('Game progress reset!'));
  194. addCheatButton('cheat7', 'Add 1 Million Hearts', () => { heartCount += 1000000; updateHeartCount(); });
  195. addCheatButton('cheat8', 'Grant All Achievements', () => alert('All achievements granted!'));
  196. addCheatButton('cheat9', 'Set Heart Multiplier to 10x', () => alert('Heart multiplier set to 10x!'));
  197. addCheatButton('cheat10', 'Unlock VIP Heart Character', () => alert('VIP Heart Character unlocked!'));
  198. addCheatButton('cheat11', 'Instant Auto-Clicker', () => alert('Auto-clicker activated!'));
  199. addCheatButton('cheat12', 'Double Upgrade Speed', () => alert('Upgrade speed doubled!'));
  200. addCheatButton('cheat13', 'Set All Upgrades to Max Level', () => alert('All upgrades set to max level!'));
  201. addCheatButton('cheat14', 'Change Background Color', () => document.body.style.backgroundColor = '#f0f0f0');
  202. addCheatButton('cheat15', 'Enable Infinite Hearts', () => alert('Infinite hearts enabled!'));
  203. addCheatButton('cheat16', 'Grant Extra Lives', () => alert('5 extra lives granted!'));
  204. addCheatButton('cheat17', 'Unlock All Characters', () => alert('All characters unlocked!'));
  205. addCheatButton('cheat18', 'Set Game Speed to Fast', () => alert('Game speed set to fast!'));
  206. addCheatButton('cheat19', 'Apply Random Upgrade', () => alert('Random upgrade applied!'));
  207. addCheatButton('cheat20', 'Reset to Default Settings', () => alert('Game settings reset to default!'));
  208.  
  209. // Restore system excluding cheats
  210. window.addEventListener('beforeunload', (event) => {
  211. const confirmationMessage = 'Are you sure you want to leave? Your progress may be lost!';
  212. event.returnValue = confirmationMessage;
  213. return confirmationMessage;
  214. });
  215.  
  216. // Example of restoring hearts on page reload
  217. function restoreProgress() {
  218. // Restore hearts and other game state from localStorage
  219. const savedHearts = localStorage.getItem('heartCount');
  220. if (savedHearts) {
  221. heartCount = parseInt(savedHearts);
  222. updateHeartCount();
  223. }
  224. }
  225.  
  226. function saveProgress() {
  227. // Save hearts and other game state to localStorage
  228. localStorage.setItem('heartCount', heartCount);
  229. }
  230.  
  231. window.addEventListener('load', restoreProgress);
  232. window.addEventListener('unload', saveProgress);
  233. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址