Blooket Hacks

Blooket hacks menu for enhancing gameplay.

当前为 2024-03-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Blooket Hacks
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Blooket hacks menu for enhancing gameplay.
  6. // @author Jesse Nicolaï
  7. // @match https://*.blooket.com/*
  8. // @icon https://ac.blooket.com/play-l/favicon.ico
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Create the menu
  17. const menuContent = document.createElement('div');
  18. menuContent.id = 'menuContent';
  19. menuContent.style.cssText = `
  20. position: fixed;
  21. top: 1%;
  22. left: 1%;
  23. color: #fff;
  24. background: #1c1c1c;
  25. padding-top: 1vh;
  26. padding-bottom: 1vh;
  27. padding-left: 3vh;
  28. padding-right: 3vh;
  29. border-radius: 12px;
  30. z-index: 9999;
  31. cursor: move;
  32. font-size: 14px; /* Adjust font size */
  33. `;
  34.  
  35. menuContent.innerHTML = `
  36. <h1 style="margin-bottom: 5px; text-align: center;">Blooket Hacks</h1>
  37. <br>
  38. <div id="menuList" style="text-align: center;">
  39. <button id="highlightAnswers" class="menu-button">Highlight Answers: Off</button><br>
  40. <button id="removeWrongAnswers" class="menu-button">Remove Wrong Answers: Off</button><br>
  41. <button id="autoAnswer" class="menu-button">Auto Answer: Off</button><br>
  42. </div>
  43. <div style="text-align: center; margin-top: 5px;">
  44. <br>
  45. <h4 style="margin: 0; padding: 0;">Press q to hide</h4><br><h5 style="margin-top: -2vh; padding: 0;">Made By Jesse Nicolai</h5>
  46. </div>
  47. `;
  48. document.body.appendChild(menuContent);
  49.  
  50. // Function to toggle the menu
  51. function toggleMenu() {
  52. menuContent.style.display = menuContent.style.display === 'none' ? 'block' : 'none';
  53. }
  54.  
  55. // Toggle the menu when the Q key is pressed
  56. document.addEventListener('keydown', function(event) {
  57. if (event.key === 'q' || event.key === 'Q') {
  58. toggleMenu();
  59. }
  60. });
  61.  
  62. // Function to toggle feature and change button style
  63. function toggleFeature(button, isActive) {
  64. if (isActive) {
  65. button.classList.add('active');
  66. button.textContent = button.textContent.replace(': Off', ': On');
  67. } else {
  68. button.classList.remove('active');
  69. button.textContent = button.textContent.replace(': On', ': Off');
  70. }
  71. }
  72.  
  73. // Toggle feature when clicking on buttons
  74. const highlightButton = document.getElementById('highlightAnswers');
  75. let highlightActive = false;
  76. let highlightInterval = null; // Variable to hold the interval ID
  77. highlightButton.addEventListener('click', function() {
  78. highlightActive = !highlightActive;
  79. toggleFeature(highlightButton, highlightActive);
  80. if (highlightActive) {
  81. // Add your code for toggling highlight answers feature here
  82. highlightInterval = setInterval(() => {
  83. const { stateNode: { state, props } } = Object.values((function react(r = document.querySelector("body>div")) { return Object.values(r)[1]?.children?.[0]?._owner.stateNode ? r : react(r.querySelector(":scope>div")) })())[1].children[0]._owner;
  84. [...document.querySelectorAll(`[class*="answerContainer"]`)].forEach((answer, i) => {
  85. if ((state.question || props.client.question).correctAnswers.includes((state.question || props.client.question).answers[i])) answer.style.backgroundColor = "rgb(0, 207, 119)";
  86. else answer.style.backgroundColor = "rgb(189, 15, 38)";
  87. });
  88. });
  89. } else {
  90. clearInterval(highlightInterval); // Stop the interval when toggled off
  91. // Reset background color of answer containers when turning off highlight
  92. [...document.querySelectorAll(`[class*="answerContainer"]`)].forEach((answer) => {
  93. answer.style.backgroundColor = "";
  94. });
  95. }
  96. });
  97.  
  98. const removeButton = document.getElementById('removeWrongAnswers');
  99. let removeActive = false;
  100. let removeInterval = null; // Variable to hold the interval ID
  101. removeButton.addEventListener('click', function() {
  102. removeActive = !removeActive;
  103. toggleFeature(removeButton, removeActive);
  104. if (removeActive) {
  105. // Add your code for toggling remove wrong answers feature here
  106. removeInterval = setInterval(() => {
  107. const { stateNode: { state, props } } = Object.values((function react(r = document.querySelector("body>div")) { return Object.values(r)[1]?.children?.[0]?._owner.stateNode ? r : react(r.querySelector(":scope>div")) })())[1].children[0]._owner;
  108. [...document.querySelectorAll(`[class*="answerContainer"]`)].forEach((answer, i) => {
  109. if (!(state.question || props.client.question).correctAnswers.includes((state.question || props.client.question).answers[i])) answer.style.display = "none";
  110. else answer.style.display = "";
  111. });
  112. });
  113. } else {
  114. clearInterval(removeInterval); // Stop the interval when toggled off
  115. // Reset display of answer containers when turning off remove wrong answers
  116. [...document.querySelectorAll(`[class*="answerContainer"]`)].forEach((answer) => {
  117. answer.style.display = "";
  118. });
  119. }
  120. });
  121.  
  122. const autoButton = document.getElementById('autoAnswer');
  123. let autoActive = false;
  124. let autoInterval = null; // Variable to hold the interval ID
  125. autoButton.addEventListener('click', function() {
  126. autoActive = !autoActive;
  127. toggleFeature(autoButton, autoActive);
  128. if (autoActive) {
  129. // Add your code for auto-answering here
  130. autoInterval = setInterval(() => {
  131. try {
  132. const { stateNode: { state, props } } = Object.values((function react(r = document.querySelector("body>div")) { return Object.values(r)[1]?.children?.[0]?._owner.stateNode ? r : react(r.querySelector(":scope>div")) })())[1].children[0]._owner;
  133. Array.from(document.querySelectorAll('div[class*="answerText"]')).filter(t => t.firstChild.innerHTML === (state.question || props.client.question).correctAnswers[0])[0].click();
  134. } catch {}
  135.  
  136. // Check for the presence of feedbackButton and click if found
  137. const feedbackButton = document.getElementById('feedbackButton');
  138. if (feedbackButton) {
  139. feedbackButton.click();
  140. }
  141. });
  142. } else {
  143. clearInterval(autoInterval); // Stop the interval when toggled off
  144. }
  145. });
  146.  
  147.  
  148. // Make the menu draggable
  149. let isDragging = false;
  150. let offsetX, offsetY;
  151.  
  152. menuContent.addEventListener('mousedown', function(event) {
  153. isDragging = true;
  154. offsetX = event.clientX - parseFloat(window.getComputedStyle(menuContent).left);
  155. offsetY = event.clientY - parseFloat(window.getComputedStyle(menuContent).top);
  156. });
  157.  
  158. document.addEventListener('mousemove', function(event) {
  159. if (isDragging) {
  160. menuContent.style.left = (event.clientX - offsetX) + 'px';
  161. menuContent.style.top = (event.clientY - offsetY) + 'px';
  162. }
  163. });
  164.  
  165. document.addEventListener('mouseup', function() {
  166. isDragging = false;
  167. });
  168.  
  169. // Style the menu
  170. GM_addStyle(`
  171. .menu-button {
  172. margin-bottom: 5px;
  173. cursor: pointer;
  174. background-color: darkred;
  175. color: #fff;
  176. border: none;
  177. padding: 5px 10px;
  178. border-radius: 3px;
  179. width: 200px;
  180. }
  181. .menu-button.active {
  182. background-color: green;
  183. }
  184. `);
  185. })();