Moomoo.io Zoom hack

Allows to change zoom of the game using mouse wheels

安装此脚本?
作者推荐脚本

您可能也喜欢Dsync Client [Sploop.io]

安装此脚本
  1. // ==UserScript==
  2. // @name Moomoo.io Zoom hack
  3. // @author Murka
  4. // @description Allows to change zoom of the game using mouse wheels
  5. // @icon https://moomoo.io/img/favicon.png?v=1
  6. // @version 0.7
  7. // @match *://moomoo.io/*
  8. // @match *://*.moomoo.io/*
  9. // @run-at document-start
  10. // @grant none
  11. // @license MIT
  12. // @namespace https://greasyfork.org/users/919633
  13. // ==/UserScript==
  14. /* jshint esversion:6 */
  15.  
  16. /*
  17. Author: Murka
  18. Github: https://github.com/Murka007
  19. Discord: https://discord.gg/sG9cyfGPj5
  20. Greasyfork: https://greasyfork.org/en/users/919633
  21. MooMooForge: https://github.com/MooMooForge
  22. */
  23.  
  24. (function() {
  25. "use strict";
  26.  
  27. const log = console.log;
  28. function linker(value) {
  29. const hook = {
  30. 0: value,
  31. toString: (radix) => hook[0].toString(radix),
  32. valueOf: () => hook[0].valueOf(),
  33. get length() {
  34. return hook[0].length;
  35. }
  36. };
  37. return hook;
  38. }
  39.  
  40. function createHook(target, prop, callback) {
  41. const symbol = Symbol(prop);
  42. Object.defineProperty(target, prop, {
  43. get() { return this[symbol]; },
  44. set(value) { callback(this, symbol, value); },
  45. configurable: true
  46. })
  47. }
  48.  
  49. createHook(window, "config", function(that, symbol, value) {
  50. if (typeof value === "object" && value.hasOwnProperty("maxScreenHeight")) {
  51. delete window.config;
  52. Object.defineProperty(window, "config", {
  53. value: value,
  54. configurable: false,
  55. writeable: false
  56. })
  57. }
  58. })
  59.  
  60. // Bypass checkTrusted, so it will just return a callback
  61. createHook(Object.prototype, "checkTrusted", function(that, symbol, value) {
  62. delete Object.prototype.checkTrusted;
  63. that.checkTrusted = (callback) => callback;
  64. })
  65.  
  66. // You can change to your own scale factor
  67. const scale = {
  68. width: 192,
  69. height: 108
  70. };
  71.  
  72. // Intercept when assigning value to maxScreenHeight, then add our hooks to it
  73. createHook(Object.prototype, "maxScreenHeight", function(that, symbol, value) {
  74. delete Object.prototype.maxScreenHeight;
  75. that.maxScreenWidth = linker(1920 + scale.width * 3);
  76. that.maxScreenHeight = linker(1080 + scale.height * 3);
  77. })
  78.  
  79. let wheels = 0;
  80. window.addEventListener("wheel", function(event) {
  81. const { maxScreenWidth, maxScreenHeight } = window.config || {};
  82. if (event.target.id !== "gameCanvas") return;
  83.  
  84. // Used to create a small gap, so users could easily find the default scale
  85. if (maxScreenWidth[0] === 1920 && maxScreenHeight[0] === 1080) wheels += 1;
  86. if (wheels % 5 !== 0) return;
  87.  
  88. const { width, height } = scale;
  89. maxScreenWidth[0] = Math.max(width, maxScreenWidth[0] + (event.deltaY > 0 ? -width : width));
  90. maxScreenHeight[0] = Math.max(height, maxScreenHeight[0] + (event.deltaY > 0 ? -height : height));
  91. window.dispatchEvent(new Event("resize"));
  92. })
  93.  
  94. })();