IdlePixel Dialogue Handler

Library which creates a modal for opening plugin panels.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greatest.deepsurf.us/scripts/527481/1540082/IdlePixel%20Dialogue%20Handler.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name			IdlePixel Dialogue Handler
// @namespace		luxferre.dev
// @version			1.0.2
// @description		Library which creates a modal for opening plugin panels.
// @author			Lux-Ferre
// @license			MIT
// @match			*://idle-pixel.com/login/play*
// @grant			none
// ==/UserScript==

(function () {
	if (window.dialoguer) {
		// already loaded
		return;
	}

	class Dialoguer {
		constructor() {
			this.original_dialogue = Modals.open_image_modal
			this.handlers = {}

			Modals.open_image_modal = function (title, image_path, message, primary_button_text, secondary_button_text, command, force_unclosable) {
				const check_text = title + image_path + message

				for (const [selector, handler] of Object.entries(window.dialoguer.handlers)) {
					if (check_text.includes(selector)) {
						[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)
						if (!handler.propagate) {
							return
						}
					}
				}

				window.dialoguer.original_dialogue(title, image_path, message, primary_button_text, secondary_button_text, command, force_unclosable)
			}
		}

		register_handler(selector, handler, propagate) {
			this.handlers[selector] = {
				handler: handler,
				propagate: propagate
			}
		}
	}

	// Add to window and init
	window.dialoguer = new Dialoguer();
})();