Move Painter with Middle Mouse Button

Allows you to drag the Painter with the Middle Mouse Button

Version vom 27.06.2021. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

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