Hunger Games Teams

Script to add teams to ice poseidons hunger games map

目前为 2024-08-16 提交的版本。查看 最新版本

// ==UserScript==
// @name         Hunger Games Teams
// @namespace    Keir
// @version      1.0
// @description  Script to add teams to ice poseidons hunger games map
// @author       KeirStarmer
// @match        https://map.iceposeidon.com/
// @match        https://hungergames.iceposeidon.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=iceposeidon.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const jsonURL = 'https://cxwatcher.github.io/teams.json';
    fetch(jsonURL)
        .then(response => response.json())
        .then(teamColors => {
            const teams = {};
            for (const [username, color] of Object.entries(teamColors)) {
                if (!teams[color]) {
                    teams[color] = [];
                }
                teams[color].push(username);
            }
            function changeUserBoxColor() {
                const usernames = document.querySelectorAll('.username');
                usernames.forEach(function(username) {
                    const name = username.textContent.trim();
                    if (teamColors[name]) {
                        username.closest('.user-marker-inner').style.backgroundColor = teamColors[name];
                    }
                });
            }

            window.addEventListener('load', changeUserBoxColor);
            new MutationObserver(changeUserBoxColor).observe(document.body, {childList: true, subtree: true});

            const gulagDiv = document.querySelector('.gulag');
            if (gulagDiv) {
                const buttonContainer = document.createElement('div');
                buttonContainer.style.marginTop = '10px';
                const buttonState = {};
                for (const [color, members] of Object.entries(teams)) {
                    const teamButton = document.createElement('button');
                    teamButton.textContent = `${color.charAt(0).toUpperCase() + color.slice(1)} Team`;
                    teamButton.style.margin = '5px';
                    teamButton.style.backgroundColor = color;
                    teamButton.style.color = color === 'yellow' || color === 'white' ? 'black' : 'white';
                    teamButton.style.border = 'none';
                    teamButton.style.padding = '5px';
                    teamButton.style.borderRadius = '5px';
                    teamButton.style.display = 'block';

                    buttonContainer.appendChild(teamButton);

                    buttonState[color] = false;

                    teamButton.addEventListener('click', () => {
                        const usernames = document.querySelectorAll('.username');
                        if (!buttonState[color]) {
                            usernames.forEach(function(username) {
                                const name = username.textContent.trim();
                                if (teamColors[name] === color) {
                                    username.closest('.user-marker-inner').style.display = 'block';
                                } else {
                                    username.closest('.user-marker-inner').style.display = 'none';
                                }
                            });
                            buttonState[color] = true;
                        } else {
                            usernames.forEach(function(username) {
                                username.closest('.user-marker-inner').style.display = 'block';
                            });
                            buttonState[color] = false;
                        }
                    });
                }
                gulagDiv.insertAdjacentElement('afterend', buttonContainer);
            }
        })
        .catch(error => console.error('Error fetching team colors:', error));
})();

QingJ © 2025

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