Agma.io linesplit controls

Linescript controls for agma.io by Wynell

目前為 2020-06-02 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Agma.io linesplit controls
// @namespace    eeWynell#4980
// @version      1.0
// @description  Linescript controls for agma.io by Wynell
// @author       eeWynell#4980
// @match        https://agma.io/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let controls = {
        generatePoint(x, y) {
            let div = document.createElement("DIV");
            div.style.border = "2px solid white";
            div.style.width = "10px";
            div.style.height = "10px";
            div.style.transform = "translate(-50%, -50%)";
            div.style.position = "fixed";
            div.style.left = `${x}px`;
            div.style.top = `${y}px`;
            div.style.zIndex = 10 ** 6;
            return div;
        },
        generateWrapper(points) {
            let div = document.createElement("DIV");
            div.id = "linesplit-controls";
            for (let point of points) {
                div.appendChild(point);
            }
            return div;
        },
        getPoints() {
            let [w, h] = [window.innerWidth, window.innerHeight];
            return [
                this.generatePoint(w / 2, 0),
                this.generatePoint(w, h / 2),
                this.generatePoint(w / 2, h),
                this.generatePoint(0, h / 2)
            ];
        },
        updateControls() {
            let points = this.getPoints();
            let wrapper = document.getElementById("linesplit-controls");
            console.log(wrapper);
            document.body.replaceChild(this.generateWrapper(points), wrapper);
        },
        createControls() {
            let points = this.getPoints();
            document.body.appendChild(this.generateWrapper(points));
        }
    };

    window.addEventListener("resize", controls.updateControls.bind(controls));
    controls.createControls();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址