Greasy Fork 还支持 简体中文。

AutoHeal(CAVEGAME.IO)

If this causes lag or your PvP isn't great because of it — learn to play on your own

  1. // ==UserScript==
  2. // @name AutoHeal(CAVEGAME.IO)
  3. // @namespace Violentmonkey Scripts
  4. // @match https://cavegame.io/*
  5. // @grant none
  6. // @version 1.0
  7. // @author Drik
  8. // @description If this causes lag or your PvP isn't great because of it — learn to play on your own
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12.  
  13. (function () {
  14. let autoHeal = false;
  15. let isHealing = false;
  16. let wsList = [];
  17.  
  18. const _send = WebSocket.prototype.send;
  19. WebSocket.prototype.send = function (data) {
  20. if (!wsList.includes(this)) wsList.push(this);
  21. _send.call(this, data);
  22. };
  23.  
  24. const getRealHP = () => {
  25. const objs = window.Phaser?.Display?.Canvas?.CanvasPool?.pool?.[1]
  26. ?.parent?.game?.events?._events?.destroy?.[5]
  27. ?.context?.events?._events?.gameout?.[0]
  28. ?.context?._events?.pointerdown?.context
  29. ?.sys?.scale?._events?.resize?.[1]
  30. ?.context?.scene?.sys?.events?._events?.start?.[3]
  31. ?.context?.manager?.keys?.MiniMap
  32. ?.sys?.settings?.data?.objs || {};
  33. for (let key in objs) {
  34. const obj = objs[key];
  35. if (obj && typeof obj.health === 'number') return obj.health;
  36. }
  37. return 100;
  38. };
  39.  
  40. const ui = document.createElement('div');
  41. ui.textContent = 'AutoHeal: OFF';
  42. ui.style.position = 'fixed';
  43. ui.style.top = '10px';
  44. ui.style.left = '10px';
  45. ui.style.padding = '6px 12px';
  46. ui.style.background = 'rgba(0,0,0,0.7)';
  47. ui.style.color = '#f00';
  48. ui.style.fontFamily = 'monospace';
  49. ui.style.fontSize = '14px';
  50. ui.style.borderRadius = '6px';
  51. ui.style.zIndex = '9999';
  52. document.body.appendChild(ui);
  53.  
  54. function updateUI() {
  55. ui.textContent = 'AutoHeal: ' + (autoHeal ? 'ON' : 'OFF');
  56. ui.style.color = autoHeal ? '#0f0' : '#f00';
  57. }
  58.  
  59. document.addEventListener('keydown', (e) => {
  60. if (e.key === 'F4') {
  61. autoHeal = !autoHeal;
  62. updateUI();
  63. }
  64. });
  65.  
  66. setInterval(() => {
  67. if (!autoHeal || isHealing) return;
  68.  
  69. const hp = getRealHP();
  70. if (hp >= 73) return;
  71.  
  72. const soup = document.querySelector('.inv-drag img[src="/asset/scaled/stew.png"]');
  73. if (!soup) return;
  74.  
  75. isHealing = true;
  76. soup.click();
  77.  
  78. const press = new Uint8Array([14, 1]);
  79. const release = new Uint8Array([14, 0]);
  80.  
  81. wsList.forEach(ws => {
  82. if (ws.readyState === WebSocket.OPEN) ws.send(press);
  83. });
  84.  
  85. setTimeout(() => {
  86. wsList.forEach(ws => {
  87. if (ws.readyState === WebSocket.OPEN) ws.send(release);
  88. });
  89. isHealing = false;
  90. }, 550);
  91. }, 20);
  92. })();