OWOP voider for ourworldofpixels

Automatically voids an area you specify. Cursor movements are currently not supported

当前为 2018-10-21 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// Made by voyager, improved by Dilan
// ==UserScript==
// @name         OWOP voider for ourworldofpixels
// @match        *.ourworldofpixels.com/*
// @description Automatically voids an area you specify. Cursor movements are currently not supported
// @version 1.2
// @namespace https://greasyfork.org/users/220233
// ==/UserScript==
var x1 = 0;
var y1 = 0;
var x2 = 0;
var y2 = 0;
var r;
var g;
var b;
function hexToRgb(hex) {
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)
    } : null;
}
function run()
{
    var running = setInterval(function() {
        for (var i = 0; i < Math.abs(x2 - x1); i++) {
            for (var j = 0; j < Math.abs(y2 - y1); j++) {
                if (OWOP.world.getPixel(i + x1, j + y1) != [r, g, b]) {
                    OWOP.world.setPixel(i + x1, j + y1, [r, g, b], false);
                }
            }
        }
    }, 1);
}
function openSeekbarWindow() {
    OWOP.windowSys.addWindow(new OWOP.windowSys.class.window('VOIDER BY VOYAGER', {}, function(win) {
        win.container.title = 'Voids an area';
        win.container.style.height = 'auto';
        win.container.style.width = '100px';
        win.container.style.overflow = 'hidden';
        win.addObj(document.createTextNode('X1 : '));
        var inputx1 = OWOP.util.mkHTML('input', {
            id: 'x1input',
            oninput: function() {
                x1 = parseInt(this.value);
            }
        });
        win.addObj(inputx1);
        win.addObj(document.createTextNode('Y1 : '));
        var inputy1 = OWOP.util.mkHTML('input', {
            id: 'y1input',
            oninput: function() {
                y1 = parseInt(this.value);
            }
        });
        win.addObj(inputy1);
        win.addObj(document.createTextNode('X2 : '));
        var inputx2 = OWOP.util.mkHTML('input', {
            id: 'x2input',
            oninput: function() {
                x2 = parseInt(this.value);
            }
        });
        win.addObj(inputx2);
        win.addObj(document.createTextNode('Y2 : '));
        var inputy2 = OWOP.util.mkHTML('input', {
            id: 'y2input',
            oninput: function() {
                y2 = parseInt(this.value);
            }
        });
        win.addObj(inputy2);
        win.addObj(document.createTextNode('Color : '));
        var colorin = OWOP.util.mkHTML('input', {
            type: 'color',
            id: 'voidcolor',
            onchange: function() {
                r = hexToRgb(this.value).r;
                g = hexToRgb(this.value).g;
                b = hexToRgb(this.value).b;
            }
        });
        win.addObj(colorin);
        var button = OWOP.util.mkHTML('button', {
            id: 'voidbutton',
            innerHTML: 'Void!',
            onclick: function() {
                if (document.getElementById("x1input").value != "") {
                    if (document.getElementById("y1input").value != "") {
                        if (document.getElementById("x2input").value != "") {
                            if (document.getElementById("y2input").value != "") {
                                run();
                            }
                        }
                    }
                }
            }
        });
        win.addObj(button);
    }).move(window.innerWidth - 500, 32));
}

if (typeof OWOP != 'undefined') openSeekbarWindow();
window.addEventListener('load', function() {
    setTimeout(openSeekbarWindow, 1234);
});