Sploop.io Hat Hotkeys

Allows to equip hats by pressing keys!

  1. // ==UserScript==
  2. // @name Sploop.io Hat Hotkeys
  3. // @author Murka
  4. // @description Allows to equip hats by pressing keys!
  5. // @icon https://sploop.io/img/ui/favicon.png
  6. // @version 0.2
  7. // @match *://sploop.io/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://gf.qytechs.cn/users/919633
  12. // ==/UserScript==
  13. /* jshint esversion:8 */
  14. /*
  15. Author: Murka
  16. Github: https://github.com/Murka007
  17. Discord: https://discord.gg/sG9cyfGPj5
  18. Greasyfork: https://gf.qytechs.cn/en/users/919633
  19. */
  20. (function() {
  21. "use strict";
  22. const HATS = {
  23. BUSH_HAT: 0,
  24. BERSERKER: 1,
  25. JUNGLE_GEAR: 2,
  26. CRYSTAL_GEAR: 3,
  27. SPIKE_GEAR: 4,
  28. IMMUNITY_GEAR: 5,
  29. BOOST_HAT: 6,
  30. APPLE_HAT: 7,
  31. SCUBA_GEAR: 8,
  32. HOOD: 9,
  33. DEMOLIST: 10
  34. };
  35. // Change your keybinds if you need to, get list of the key codes here: https://keycode.info
  36. // Please use `event.code` to change keybind
  37. // If you don't need a keybind, leave the field empty ""
  38. const KEYBINDS = {
  39. [HATS.BUSH_HAT]: "",
  40. [HATS.BERSERKER]: "Key1",
  41. [HATS.JUNGLE_GEAR]: "",
  42. [HATS.CRYSTAL_GEAR]: "KeyF",
  43. [HATS.SPIKE_GEAR]: "KeyC",
  44. [HATS.IMMUNITY_GEAR]: "KeyV",
  45. [HATS.BOOST_HAT]: "KeyR",
  46. [HATS.APPLE_HAT]: "",
  47. [HATS.SCUBA_GEAR]: "",
  48. [HATS.HOOD]: "KeyO",
  49. [HATS.DEMOLIST]: "Key2"
  50. };
  51. // HAT EQUIP LOGIC GOES BELOW
  52. const log = console.log;
  53. const storage = {
  54. get(key) {
  55. const value = localStorage.getItem(key);
  56. return value === null ? null : JSON.parse(value);
  57. },
  58. set(key, value) {
  59. localStorage.setItem(key, JSON.stringify(value));
  60. }
  61. };
  62. function sleep(ms) {
  63. return new Promise(resolve => setTimeout(resolve, ms));
  64. }
  65. function isInput() {
  66. return document.activeElement.tagName === "INPUT";
  67. }
  68. function inGame() {
  69. const homepage = document.querySelector("#homepage");
  70. return homepage && homepage.style.display !== "flex";
  71. }
  72. function canEquip() {
  73. return !isInput() && inGame();
  74. }
  75. function createKeyboardEvent(type, code) {
  76. return new Proxy(new KeyboardEvent(type), {
  77. get(target, prop) {
  78. if (prop === "isTrusted") return true;
  79. if (prop === "target") return document.body;
  80. if (prop === "code") return code;
  81. return target[prop];
  82. }
  83. })
  84. }
  85. function keypress(code) {
  86. const keydown = createKeyboardEvent("keydown", code);
  87. const keyup = createKeyboardEvent("keyup", code);
  88. window.onkeydown(keydown);
  89. window.onkeyup(keyup);
  90. }
  91. function mouseup(target) {
  92. target.onmouseup(new Proxy(new MouseEvent("mouseup"), {
  93. get(target, prop) {
  94. if (prop === "isTrusted") return true;
  95. if (prop === "target") return target;
  96. return target[prop];
  97. }
  98. }));
  99. }
  100. let equipToggle = false;
  101. async function equipHat(index) {
  102. if (!canEquip() || equipToggle) return;
  103. equipToggle = true;
  104. const hatActionButton = document.querySelectorAll(".hat_action_button")[index];
  105. if (!hatActionButton) throw new Error("Failed to find hat with index: " + index);
  106. const keybinds = storage.get("keybinds");
  107. const OpenShopKey = keybinds && keybinds[18] || "KeyN";
  108. keypress(OpenShopKey);
  109. await sleep(150);
  110. if (hatActionButton.textContent === "BUY") {
  111. mouseup(hatActionButton);
  112. }
  113. mouseup(hatActionButton);
  114. await sleep(150);
  115. keypress(OpenShopKey);
  116. await sleep(1500);
  117. equipToggle = false;
  118. }
  119. window.addEventListener("keydown", function(event) {
  120. if (event.repeat) return;
  121. for (const key in KEYBINDS) {
  122. if (event.code === KEYBINDS[key]) {
  123. equipHat(key);
  124. break;
  125. }
  126. }
  127. })
  128. })();

QingJ © 2025

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