Move Painter with Middle Mouse Button

Allows you to drag the Painter with the Middle Mouse Button

اعتبارا من 27-06-2021. شاهد أحدث إصدار.

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

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.

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

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

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