Speed Up Time Script

Tăng tốc thời gian trên trang web khi nhấp vào phần tử cụ thể

  1. // ==UserScript==
  2. // @name Speed Up Time Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Tăng tốc thời gian trên trang web khi nhấp vào phần tử cụ thể
  6. // @author Your Name
  7. // @match *://*/*
  8. // @grant none
  9. // @license Hi
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function findAndClickElementById() {
  16. const elementId = '#layma_me_vuatraffic';
  17. const element = document.querySelector(elementId);
  18.  
  19. if (element) {
  20. console.log(`Element found: ${elementId}`);
  21. element.click();
  22. setTimeout(() => {
  23. activateSpeedUpTime();
  24. console.log("Clicked on the element and activated speed up.");
  25. }, 3000); // Đợi 3 giây trước khi kích hoạt tăng tốc
  26. } else {
  27. console.log(`Element not found: ${elementId}`);
  28. }
  29. }
  30.  
  31. function activateSpeedUpTime() {
  32. console.log("Activating Speed Up Time");
  33.  
  34. let speedConfig = {
  35. speed: 100.0,
  36. cbSetIntervalChecked: true,
  37. cbSetTimeoutChecked: true,
  38. cbPerformanceNowChecked: true,
  39. cbDateNowChecked: true,
  40. cbRequestAnimationFrameChecked: true,
  41. };
  42.  
  43. const emptyFunction = () => {};
  44.  
  45. const originalClearInterval = window.clearInterval;
  46. const originalclearTimeout = window.clearTimeout;
  47.  
  48. const originalSetInterval = window.setInterval;
  49. const originalSetTimeout = window.setTimeout;
  50.  
  51. const originalPerformanceNow = window.performance.now.bind(
  52. window.performance
  53. );
  54.  
  55. const originalDateNow = Date.now;
  56.  
  57. const originalRequestAnimationFrame = window.requestAnimationFrame;
  58.  
  59. let timers = [];
  60. const reloadTimers = () => {
  61. console.log(timers);
  62. const newtimers = [];
  63. timers.forEach((timer) => {
  64. originalClearInterval(timer.id);
  65. if (timer.customTimerId) {
  66. originalClearInterval(timer.customTimerId);
  67. }
  68. if (!timer.finished) {
  69. const newTimerId = originalSetInterval(
  70. timer.handler,
  71. speedConfig.cbSetIntervalChecked
  72. ? timer.timeout / speedConfig.speed
  73. : timer.timeout,
  74. ...timer.args
  75. );
  76. timer.customTimerId = newTimerId;
  77. newtimers.push(timer);
  78. }
  79. });
  80. timers = newtimers;
  81. };
  82.  
  83. window.addEventListener("message", (e) => {
  84. if (e.data.command === "setSpeedConfig") {
  85. speedConfig = e.data.config;
  86. reloadTimers();
  87. }
  88. });
  89.  
  90. window.postMessage({ command: "getSpeedConfig" });
  91.  
  92. window.clearInterval = (id) => {
  93. originalClearInterval(id);
  94. timers.forEach((timer) => {
  95. if (timer.id == id) {
  96. timer.finished = true;
  97. if (timer.customTimerId) {
  98. originalClearInterval(timer.customTimerId);
  99. }
  100. }
  101. });
  102. };
  103.  
  104. window.clearTimeout = (id) => {
  105. originalclearTimeout(id);
  106. timers.forEach((timer) => {
  107. if (timer.id == id) {
  108. timer.finished = true;
  109. if (timer.customTimerId) {
  110. originalclearTimeout(timer.customTimerId);
  111. }
  112. }
  113. });
  114. };
  115.  
  116. window.setInterval = (handler, timeout, ...args) => {
  117. console.log("timeout ", timeout);
  118. if (!timeout) timeout = 0;
  119. const id = originalSetInterval(
  120. handler,
  121. speedConfig.cbSetIntervalChecked ? timeout / speedConfig.speed : timeout,
  122. ...args
  123. );
  124. timers.push({
  125. id: id,
  126. handler: handler,
  127. timeout: timeout,
  128. args: args,
  129. finished: false,
  130. customTimerId: null,
  131. });
  132. return id;
  133. };
  134.  
  135. window.setTimeout = (handler, timeout, ...args) => {
  136. if (!timeout) timeout = 0;
  137. return originalSetTimeout(
  138. handler,
  139. speedConfig.cbSetTimeoutChecked ? timeout / speedConfig.speed : timeout,
  140. ...args
  141. );
  142. };
  143.  
  144. // performance.now
  145. (function () {
  146. let performanceNowValue = null;
  147. let previousPerformanceNowValue = null;
  148. window.performance.now = () => {
  149. const originalValue = originalPerformanceNow();
  150. if (performanceNowValue) {
  151. performanceNowValue +=
  152. (originalValue - previousPerformanceNowValue) *
  153. (speedConfig.cbPerformanceNowChecked ? speedConfig.speed : 1);
  154. } else {
  155. performanceNowValue = originalValue;
  156. }
  157. previousPerformanceNowValue = originalValue;
  158. return Math.floor(performanceNowValue);
  159. };
  160. })();
  161.  
  162. // Date.now
  163. (function () {
  164. let dateNowValue = null;
  165. let previousDateNowValue = null;
  166. Date.now = () => {
  167. const originalValue = originalDateNow();
  168. if (dateNowValue) {
  169. dateNowValue +=
  170. (originalValue - previousDateNowValue) *
  171. (speedConfig.cbDateNowChecked ? speedConfig.speed : 1);
  172. } else {
  173. dateNowValue = originalValue;
  174. }
  175. previousDateNowValue = originalValue;
  176. return Math.floor(dateNowValue);
  177. };
  178. })();
  179.  
  180. // requestAnimationFrame
  181. (function () {
  182. let dateNowValue = null;
  183. let previousDateNowValue = null;
  184. const callbackFunctions = [];
  185. const callbackTick = [];
  186. const newRequestAnimationFrame = (callback) => {
  187. return originalRequestAnimationFrame((timestamp) => {
  188. const originalValue = originalDateNow();
  189. if (dateNowValue) {
  190. dateNowValue +=
  191. (originalValue - previousDateNowValue) *
  192. (speedConfig.cbRequestAnimationFrameChecked
  193. ? speedConfig.speed
  194. : 1);
  195. } else {
  196. dateNowValue = originalValue;
  197. }
  198. previousDateNowValue = originalValue;
  199.  
  200. const dateNowValue_MathFloor = Math.floor(dateNowValue);
  201.  
  202. const index = callbackFunctions.indexOf(callback);
  203. let tickFrame = null;
  204. if (index === -1) {
  205. callbackFunctions.push(callback);
  206. callbackTick.push(0);
  207. callback(dateNowValue_MathFloor);
  208. } else if (speedConfig.cbRequestAnimationFrameChecked) {
  209. tickFrame = callbackTick[index];
  210. tickFrame += speedConfig.speed;
  211.  
  212. if (tickFrame >= 1) {
  213. while (tickFrame >= 1) {
  214. callback(dateNowValue_MathFloor);
  215. window.requestAnimationFrame = emptyFunction;
  216. tickFrame -= 1;
  217. }
  218. window.requestAnimationFrame = newRequestAnimationFrame;
  219. } else {
  220. window.requestAnimationFrame(callback);
  221. }
  222. callbackTick[index] = tickFrame;
  223. } else {
  224. callback(dateNowValue_MathFloor);
  225. }
  226. });
  227. };
  228. window.requestAnimationFrame = newRequestAnimationFrame;
  229. })();
  230. }
  231.  
  232. // Gọi hàm để kiểm tra
  233. findAndClickElementById();
  234. })();