Move Painter with Middle Mouse Button

Allows you to drag the Painter with the Middle Mouse Button

Versión del día 27/6/2021. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Move Painter with Middle Mouse Button
// @namespace    http://tampermonkey.com/
// @version      1.0
// @description  Allows you to drag the Painter with the Middle Mouse Button
// @author       MTP3
// @match        http://manyland.com/*
// @icon         http://manyland.com/favicon.ico
// @grant        none
// ==/UserScript==

let replacePainter = () => {
	if (ig.game.painter.movable)
	{
		ig.game.sounds.success.play();
		return;
	}

	let teleportElement = (element, x, y) => {
		if (!element)
			return;

		jQuery(element).css("left", x + "px");
		jQuery(element).css("top", y + "px");
	};

	let offsetElement = (element, x, y) => {
		if (!element)
			return;

		let pos = jQuery(element).position();

		teleportElement(element, x + pos.left, y + pos.top);
	};

	ig.game.painter.updateCursorPos = (e) => {
		if (!ig.game.painter.isRunning)
			ig.game.painter.moving = false;

		if (!ig.game.painter.moving)
			return;

		let painter = ig.game.painter;

		let pos = jQuery(ig.game.painter.canvas).position();
		let x = e.movementX;
		let y = e.movementY;

		offsetElement(ig.game.painter.canvas, x, y);
		offsetElement($(".painterInputBox")[0], x, y);

		ig.game.painter.oldMouseX = e.offsetX;
		ig.game.painter.oldMouseY = e.offsetY;
	};

	document.addEventListener('mousemove', ig.game.painter.updateCursorPos);

	document.addEventListener('mousedown', (e) => {
		if (e.button == 1)
			ig.game.painter.moving = true;
	});

	document.addEventListener('mouseup', (e) => {
		if (e.button == 1)
			ig.game.painter.moving = false;
	});

	ig.game.painter.movable = true;

	ig.game.sounds.success.play();
};

(() => {
	let loading = setInterval(() => {
		if      (ig === undefined) return;
        else if (ig.input === undefined) return;
        else if (ig.game === undefined) return;
        else if (ig.game.painter === undefined) return;

        clearInterval(loading);
		replacePainter();
    }, 250);
})();