SPlex.gg Attack-Hide and Sort -Update

avatar
(Edited)

DE (EN below)

Hallo liebe Community,

mein letzter Beitrag ist schon wieder über 2 Wochen her, den ich eigentlich schon wenige Zeit nach dem Veröffentlichen überarbeiten wollte. Leider kam ich dann ins Krankenhaus.

Da es eine Änderung bei Golem Overlord gab, funktionierte das Script nicht mehr.

Hier nun endlich das Update dazu:

// ==UserScript==
// @name         SPlex.gg Attack-Hide
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Add a button to hide divs with class "protection_remove" on https://go.splex.gg/
// @author       louis88 + ChatGPT
// @match        https://go.splex.gg/*
// @require https://cdn.rawgit.com/thekit/jquery.waitforkeyelements/1.4.0/dist/jquery.waitForKeyElements.min.js
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Function for hiding divs with the "protection_remove" class
    function hideDivsWithClass() {
        const divs = document.querySelectorAll('div.protection_remove');
        divs.forEach(div => {
            const tr = div.closest('tr');

            if (tr) {
                tr.style.display = 'none';
            }
        });

        sortTableByStealValue();
    }



    function sortTableByStealValue() {
        console.log("tablesort");
        var table = document.querySelector("table.go_menu_no_pad"); // Die Tabelle auswählen
        var rows = Array.from(table.querySelectorAll("tr.attack_lb")); // Alle Zeilen auswählen und in ein Array umwandeln

        // Die Zeilen sortieren
        rows.sort(function (a, b) {
            console.log(a,b);
            var spanA = a.querySelector(".lb_steal span"); // Das span-Element in der ersten Zeile
            var spanB = b.querySelector(".lb_steal span"); // Das span-Element in der zweiten Zeile
            var valueA = parseFloat(spanA.textContent.replace("~","")); // Den Wert in der ersten Zeile extrahieren und in eine Fließkommazahl umwandeln
            var valueB = parseFloat(spanB.textContent.replace("~","")); // Den Wert in der zweiten Zeile extrahieren und in eine Fließkommazahl umwandeln

            // Vergleiche die Werte und sortiere die Zeilen aufsteigend
            return valueB - valueA;
        });

        // Die sortierten Zeilen zur Tabelle hinzufügen
        var tbody = table.querySelector("tbody");
        rows.forEach(function (row) {
            tbody.appendChild(row);
        });
    }



    // Function to create the button and define the click behaviour
    function createHideButton() {
        const button = document.createElement('button');
        button.innerText = 'Hide Players';
        button.style.position = 'fixed';
        button.style.top = '50%';
        button.style.right = '10px';
        button.style.transform = 'translateY(-50%)';
        button.style.zIndex = '9999'; // Hocher Z-Index
        button.addEventListener('click', hideDivsWithClass);
        document.body.appendChild(button);
    }

    // Add CSS styles to format the button
    GM_addStyle(`
        button {
            padding: 25px;
            background-color: #007BFF;
            color: white;
            border: none;
            cursor: pointer;
        }
    `);

    function addMaxUpgrade(){

     $(".upgrade").on("click", function() {

       waitForKeyElements("div.go_menu_body > div.row > div > img.small_upgrade_skill_2",addMaxUpgradeOnclick);
    });


    }

    function addMaxUpgradeOnclick(){
        $("div.go_menu_body > div.row > div > img.small_upgrade_skill_2").on("click", function() {
            console.log("blub");
        });
    }


    // Create the button and add it to the page
    createHideButton();
    addMaxUpgrade();
    console.log("Blub",window.jQuery);

})();


Das Update findet ihr hier:
https://jsfiddle.net/hive_coding/dn2q075g/3/
Es ist ein Script für Tampermonkey!

EN

Hello dear community,

my last post was more than 2 weeks ago, which I actually wanted to revise a short time after publishing it. Unfortunately I ended up in hospital.

Since there was a change at Golem Overlord, the script didn't work anymore.

Here is the update at last:

// ==UserScript==
// @name         SPlex.gg Attack-Hide
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Add a button to hide divs with class "protection_remove" on https://go.splex.gg/
// @author       louis88 + ChatGPT
// @match        https://go.splex.gg/*
// @require https://cdn.rawgit.com/thekit/jquery.waitforkeyelements/1.4.0/dist/jquery.waitForKeyElements.min.js
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Function for hiding divs with the "protection_remove" class
    function hideDivsWithClass() {
        const divs = document.querySelectorAll('div.protection_remove');
        divs.forEach(div => {
            const tr = div.closest('tr');

            if (tr) {
                tr.style.display = 'none';
            }
        });

        sortTableByStealValue();
    }



    function sortTableByStealValue() {
        console.log("tablesort");
        var table = document.querySelector("table.go_menu_no_pad"); // Die Tabelle auswählen
        var rows = Array.from(table.querySelectorAll("tr.attack_lb")); // Alle Zeilen auswählen und in ein Array umwandeln

        // Die Zeilen sortieren
        rows.sort(function (a, b) {
            console.log(a,b);
            var spanA = a.querySelector(".lb_steal span"); // Das span-Element in der ersten Zeile
            var spanB = b.querySelector(".lb_steal span"); // Das span-Element in der zweiten Zeile
            var valueA = parseFloat(spanA.textContent.replace("~","")); // Den Wert in der ersten Zeile extrahieren und in eine Fließkommazahl umwandeln
            var valueB = parseFloat(spanB.textContent.replace("~","")); // Den Wert in der zweiten Zeile extrahieren und in eine Fließkommazahl umwandeln

            // Vergleiche die Werte und sortiere die Zeilen aufsteigend
            return valueB - valueA;
        });

        // Die sortierten Zeilen zur Tabelle hinzufügen
        var tbody = table.querySelector("tbody");
        rows.forEach(function (row) {
            tbody.appendChild(row);
        });
    }



    // Function to create the button and define the click behaviour
    function createHideButton() {
        const button = document.createElement('button');
        button.innerText = 'Hide Players';
        button.style.position = 'fixed';
        button.style.top = '50%';
        button.style.right = '10px';
        button.style.transform = 'translateY(-50%)';
        button.style.zIndex = '9999'; // Hocher Z-Index
        button.addEventListener('click', hideDivsWithClass);
        document.body.appendChild(button);
    }

    // Add CSS styles to format the button
    GM_addStyle(`
        button {
            padding: 25px;
            background-color: #007BFF;
            color: white;
            border: none;
            cursor: pointer;
        }
    `);

    function addMaxUpgrade(){

     $(".upgrade").on("click", function() {

       waitForKeyElements("div.go_menu_body > div.row > div > img.small_upgrade_skill_2",addMaxUpgradeOnclick);
    });


    }

    function addMaxUpgradeOnclick(){
        $("div.go_menu_body > div.row > div > img.small_upgrade_skill_2").on("click", function() {
            console.log("blub");
        });
    }


    // Create the button and add it to the page
    createHideButton();
    addMaxUpgrade();
    console.log("Blub",window.jQuery);

})();


You can find the update here:
https://jsfiddle.net/hive_coding/dn2q075g/3/
It is a script for Tampermonkey!



0
0
0.000
4 comments
avatar

!LUV für Programmierer, die ihre Arbeiten veröffentlichen! :-)

0
0
0.000
avatar

Could you describe this more? I did not understand what it does that attack

0
0
0.000