CHECKMATE

take over the earth with this

// ==UserScript==
// @name         CHECKMATE
// @namespace    -
// @version      0.1
// @description  take over the earth with this
// @author       feature aka phytonx
// @match        *://*.moomoo.io/*
// @license      MIT
// @grant        none
// ==/UserScript==
class dark {
    constructor() {
        this.canvas = document.createElement("canvas");
        this.canvas.id = "darkMode";
        this.canvas.style.position = "fixed";
        this.canvas.style.top = "0";
        this.canvas.style.left = "0";
        this.canvas.style.pointerEvents = "none";
        this.canvas.style.width = "100%";
        this.canvas.style.height = "100%";
        this.canvas.style.zIndex = "9999";

        document.body.appendChild(this.canvas);

        this.context = this.canvas.getContext("2d");

        this.drawBackground();
        
        window.addEventListener("resize", this.drawBackground.bind(this));
        document.addEventListener("mousedown", this.dark.bind(this));
        document.addEventListener("mouseup", this.dark.bind(this));
        document.addEventListener("mousemove", this.dark.bind(this));
    }

    drawBackground() {
        this.canvas.width = window.innerWidth;
        this.canvas.height = window.innerHeight;

        this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);

        let grid= 100;
        let num = Math.ceil(this.canvas.height / grid);
        let numCol = Math.ceil(this.canvas.width / grid);

        for (let row = 0; row < num; row++) {
            for (let col = 0; col < numCol; col++) {
                let x = col * grid;
                let y = row * grid;

                this.context.fillStyle = (row + col) % 2 === 0 ? "rgba(0, 0, 0, 0.9)" : "rgba(0, 0, 0, 0.8)";
                this.context.fillRect(x, y, grid, grid);
            }
        }
    }

    dark(event) {
        var eventClone = new MouseEvent(event.type, event);
        document.dispatchEvent(eventClone);
    }
}

const darkModeCanvas = new dark();