IdlePixel Dialogue Handler

Library which creates a modal for opening plugin panels.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greatest.deepsurf.us/scripts/527481/1540082/IdlePixel%20Dialogue%20Handler.js

  1. // ==UserScript==
  2. // @name IdlePixel Dialogue Handler
  3. // @namespace luxferre.dev
  4. // @version 1.0.2
  5. // @description Library which creates a modal for opening plugin panels.
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. if (window.dialoguer) {
  14. // already loaded
  15. return;
  16. }
  17.  
  18. class Dialoguer {
  19. constructor() {
  20. this.original_dialogue = Modals.open_image_modal
  21. this.handlers = {}
  22.  
  23. Modals.open_image_modal = function (title, image_path, message, primary_button_text, secondary_button_text, command, force_unclosable) {
  24. const check_text = title + image_path + message
  25.  
  26. for (const [selector, handler] of Object.entries(window.dialoguer.handlers)) {
  27. if (check_text.includes(selector)) {
  28. [title, image_path, message, primary_button_text, secondary_button_text, command, force_unclosable] = handler.handler(title, image_path, message, primary_button_text, secondary_button_text, command, force_unclosable)
  29. if (!handler.propagate) {
  30. return
  31. }
  32. }
  33. }
  34.  
  35. window.dialoguer.original_dialogue(title, image_path, message, primary_button_text, secondary_button_text, command, force_unclosable)
  36. }
  37. }
  38.  
  39. register_handler(selector, handler, propagate) {
  40. this.handlers[selector] = {
  41. handler: handler,
  42. propagate: propagate
  43. }
  44. }
  45. }
  46.  
  47. // Add to window and init
  48. window.dialoguer = new Dialoguer();
  49. })();