IdlePixel Tick Pulse

Adds a little circle that pulses each combat tick.

  1. // ==UserScript==
  2. // @name IdlePixel Tick Pulse
  3. // @namespace com.anwinity.idlepixel
  4. // @version 1.0.1
  5. // @description Adds a little circle that pulses each combat tick.
  6. // @author Anwinity
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const PULSE_DURATION = 500;
  17.  
  18. class TickPulsePlugin extends IdlePixelPlusPlugin {
  19. constructor() {
  20. super("tickpulse", {
  21. about: {
  22. name: GM_info.script.name,
  23. version: GM_info.script.version,
  24. author: GM_info.script.author,
  25. description: GM_info.script.description
  26. }
  27. });
  28. }
  29.  
  30. pulse() {
  31. const circle = $("#pulse-circle");
  32. circle.removeAttr("style");
  33. circle.animate({
  34. "width": "40px",
  35. "height": "40px",
  36. "margin-top": "-20px",
  37. "margin-left": "-20px",
  38. "opacity": 0
  39. }, PULSE_DURATION, "swing");
  40. }
  41.  
  42. onMessageReceived(data) {
  43. if(data.includes("ANIMATE")) {
  44. console.log(data);
  45. }
  46. if(data.startsWith("SET_ITEMS=") && data.includes("hp~") && !data.includes("playtime~")) {
  47. this.pulse();
  48. }
  49. }
  50.  
  51. onLogin() {
  52. $("head").append(`
  53. <style id="styles-tickpulse">
  54. #pulse-circle {
  55. width: 0px;
  56. height: 0px;
  57. margin-top: 0px;
  58. margin-left: 0px;
  59. border-radius: 20px;
  60. background: rgb(42, 200, 200);
  61. opacity: 1;
  62. }
  63. </style>
  64. `);
  65. $("#combat-presets-area").closest("td").next("td").append('<div id="pulse-circle"></div>');
  66. }
  67.  
  68. }
  69.  
  70. const plugin = new TickPulsePlugin();
  71. IdlePixelPlus.registerPlugin(plugin);
  72.  
  73. })();