Autodarts shared board script

Auto remove board user and auto 'use my board' on every user that joins

As of 26/02/2024. See the latest version.

// ==UserScript==
// @name         Autodarts shared board script
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Auto remove board user and auto 'use my board' on every user that joins
// @author       Senne
// @match        *//:autodarts.io/lobbies/*
// @match        *autodarts.io/lobbies/*
// @match        *autodarts.io/*
// @match        play.autodarts.io/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @run-at       document-end
// ==/UserScript==

const username = "USERNAME";

var MutationObserver = window.MutationObserver;
var myObserver = new MutationObserver(mutationHandler);
var obsConfig = {
    childList: true, attributes: true,
    subtree: true, attributeFilter: ['class']
};

myObserver.observe(document, obsConfig);

function mutationHandler(mutationRecords) {

    mutationRecords.forEach(function (mutation) {

        if (mutation.type == "childList" && 
        typeof mutation.addedNodes == "object" &&
        mutation.addedNodes.length
        ) {
            for (var J = 0, L = mutation.addedNodes.length; J < L; ++J) {
                checkForCSS_Class(mutation.addedNodes[J]);
            }
        }
        else if (mutation.type == "attributes") {
            checkForCSS_Class(mutation.target);
        }
    });
}
function checkForCSS_Class(node) {
    //-- Only process element nodes
    if (node.classList.value === "chakra-card css-1iwnx83") {
        console.log(node.classList.value);
        var elements = node.getElementsByClassName("chakra-table css-5605sr");
        if (elements.length === 1) {
            var rows = elements[0].getElementsByClassName("css-0");
            Array.from(rows).forEach(row => deleteTeal(row));
        }
    }
    else if (node.classList.value === "css-0") {
        deleteUser(node);
    }
}

function deleteUser(node) {
    var tableRow = node.getElementsByClassName("css-1ny2kle");
    if (tableRow.length === 0) {
        tableRow = node.getElementsByClassName("css-bqo804");
        if (tableRow.length === 0) {
            return;
        }
    }
    var nameNode = tableRow[0].childNodes[0].nodeValue;
    if (nameNode === username) {
        var deleteButtons = node.getElementsByClassName("chakra-button css-16mfj2s");
        if (deleteButtons.length === 1) {
            deleteButtons[0].click();
        }
        else {
            deleteButtons = node.getElementsByClassName("chakra-button css-22xpxh");
            if (deleteButtons.length === 1) {
                deleteButtons[0].click();
            }
        }
    }
    else {
        var useBoard = node.getElementsByClassName("chakra-button css-1e89954");
        if (useBoard.length === 1) {
            useBoard[0].click();
        }
        else {
            useBoard = node.getElementsByClassName("chakra-button css-1wtemij");
            if (useBoard.length === 1) {
                useBoard[0].click();
            }
        }
    }
}
长期地址
遇到问题?请前往 GitHub 提 Issues。