IdlePixel Dialogue Handler

Library which creates a modal for opening plugin panels.

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @require https://update.greatest.deepsurf.us/scripts/527481/1540082/IdlePixel%20Dialogue%20Handler.js

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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();
})();