Sploop.io Tracers

Draws tracers on enemies, teammates and animals

Install this script?
Author's suggested script

You may also like Dsync Client [Sploop.io].

Install this script
  1. // ==UserScript==
  2. // @name Sploop.io Tracers
  3. // @author Murka
  4. // @description Draws tracers on enemies, teammates and animals
  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://greatest.deepsurf.us/users/919633
  12. // ==/UserScript==
  13. /* jshint esversion:6 */
  14.  
  15. /*
  16. Author: Murka
  17. Github: https://github.com/Murka007
  18. Discord: https://discord.gg/sG9cyfGPj5
  19. Greasyfork: https://greatest.deepsurf.us/en/users/919633
  20.  
  21. Description:
  22. - Draws tracers at enemies, teammates and animals
  23. - You can choose your tracers mode, `ARROWS` or `LINES`
  24. - If you will have any issues with this script, report about it in my discord
  25. */
  26.  
  27. (function() {
  28. "use strict";
  29.  
  30. // Customize tracers by changing values
  31. window.tracers = {
  32. mode: "ARROWS", // ARROWS, LINES
  33. color: {
  34. teammate: "#a4cc4f",
  35. enemy: "#cc5151"
  36. }
  37. };
  38.  
  39. const log = console.log;
  40. function createHook(target, prop, setter) {
  41. if (!window.hooks) {
  42. window.hooks = {
  43. setter: [],
  44. getter: []
  45. };
  46. }
  47. window.hooks.setter.push(setter);
  48.  
  49. const symbol = Symbol(prop);
  50. Object.defineProperty(target, prop, {
  51. get() {
  52. return this[symbol];
  53. },
  54. set(value) {
  55. for (const setter of window.hooks.setter) {
  56. setter(this, symbol, value);
  57. }
  58. },
  59. configurable: true
  60. })
  61. }
  62.  
  63. const myPlayer = {
  64. id: null,
  65. data: null
  66. };
  67.  
  68. // Get player id
  69. window.WebSocket = new Proxy(WebSocket, {
  70. construct(target, args) {
  71. const socket = new target(...args);
  72. socket.addEventListener("message", function(event) {
  73. try {
  74. const data = JSON.parse(event.data);
  75. if (data[0] === 35) {
  76. myPlayer.id = data[1];
  77. }
  78. } catch(err) {}
  79. })
  80. return socket;
  81. }
  82. })
  83.  
  84. createHook(Object.prototype, "i", function(that, symbol, value) {
  85. that[symbol] = value;
  86. if (myPlayer.id === value) myPlayer.data = that;
  87. });
  88.  
  89. function formatPosition(args) {
  90. const [ img, x, y ] = args;
  91. return {
  92. x: x + 0.5 * img.width / 2,
  93. y: y - 67.5
  94. };
  95. }
  96.  
  97. function triangle(ctx, x, y, width, height, angle, color) {
  98. ctx.save();
  99. ctx.translate(x, y);
  100. ctx.rotate(angle);
  101. ctx.fillStyle = color;
  102. ctx.beginPath();
  103. ctx.moveTo(width, 0);
  104. ctx.lineTo(0, -height);
  105. ctx.lineTo(-width, 0);
  106. ctx.closePath();
  107. ctx.fill();
  108. ctx.restore();
  109. }
  110.  
  111. function lines(ctx, x1, y1, x2, y2, color) {
  112. ctx.save();
  113. ctx.strokeStyle = color;
  114. ctx.lineCap = "round";
  115. ctx.lineWidth = 5;
  116. ctx.beginPath();
  117. ctx.moveTo(x1, y1);
  118. ctx.lineTo(x2, y2);
  119. ctx.stroke();
  120. ctx.restore();
  121. }
  122.  
  123. const COLOR = {
  124. TEAMMATE: "#a4cc4f",
  125. ENEMY: "#cc5151"
  126. };
  127.  
  128. // drawImage is called when the game draws a health gauge
  129. CanvasRenderingContext2D.prototype.drawImage = new Proxy(CanvasRenderingContext2D.prototype.drawImage, {
  130. apply(target, _this, args) {
  131. const data = target.apply(_this, args);
  132. const [ img, x, y, w, h ] = args;
  133. if (
  134. img instanceof HTMLCanvasElement &&
  135. [COLOR.TEAMMATE, COLOR.ENEMY].includes(_this.fillStyle) &&
  136. myPlayer.data !== null &&
  137. w === img.width * 0.5 &&
  138. h === img.height * 0.5
  139. ) {
  140. const { gU: x1, gV: y1 } = myPlayer.data;
  141. const { x: x2, y: y2 } = formatPosition(args);
  142.  
  143. const angle = Math.atan2(y2 - y1, x2 - x1);
  144. const isMyPlayer = angle === -Math.PI/2 && _this.fillStyle === COLOR.TEAMMATE;
  145. const { teammate, enemy } = window.tracers.color;
  146. const color = _this.fillStyle === COLOR.TEAMMATE ? teammate : enemy;
  147.  
  148. if (!isMyPlayer) {
  149. const x = x1 + 80 * Math.cos(angle);
  150. const y = y1 + 80 * Math.sin(angle);
  151. switch (window.tracers.mode) {
  152. case "ARROWS":
  153. triangle(_this, x, y, 15, 40, angle + Math.PI / 2, color);
  154. break;
  155. case "LINES":
  156. lines(_this, x1, y1, x2, y2, color);
  157. break;
  158. }
  159. }
  160. }
  161. return data;
  162. }
  163. })
  164.  
  165. })();