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