Nitro Type Friends List Exporter

Export racer names with gold detection, race count filtering, and ban detection

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Nitro Type Friends List Exporter
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Export racer names with gold detection, race count filtering, and ban detection
// @match        https://www.nitrotype.com/friends
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let menu = document.createElement('div');
    menu.style.position = 'fixed';
    menu.style.top = '10px';
    menu.style.right = '10px';
    menu.style.background = 'black';
    menu.style.color = 'white';
    menu.style.padding = '10px';
    menu.style.borderRadius = '5px';
    menu.style.zIndex = '10000';

    let exportButton = document.createElement('button');
    exportButton.innerText = 'Export Racer List';
    exportButton.style.padding = '5px';
    exportButton.style.cursor = 'pointer';

    menu.appendChild(exportButton);
    document.body.appendChild(menu);

    exportButton.addEventListener('click', () => {
        let racerRows = document.querySelectorAll('.table-row.friends-list--row');
        let racerList = [];

        racerRows.forEach(row => {
            let nameCell = row.querySelector('.type-ellip');
            let raceCell = row.querySelector('.table-cell.table-cell--races');
            let statusCell = row.querySelector('.table-cell.table-cell--status');

            if (nameCell && raceCell && statusCell) {
                let raceCount = parseInt(raceCell.textContent.replace(/,/g, ''));
                let isGold = nameCell.classList.contains('type-gold');
                let isBanned = statusCell.textContent.includes('Banned');

                if (!isBanned && (isGold || raceCount > 5000)) {
                    racerList.push(nameCell.textContent.trim());
                }
            }
        });

        if (racerList.length === 0) {
            showErrorMessage();
        } else {
            let data = racerList.join('\n');
            let blob = new Blob([data], { type: 'text/plain' });
            let a = document.createElement('a');
            a.href = URL.createObjectURL(blob);
            a.download = 'top_racers.txt';
            a.click();
        }
    });

    function showErrorMessage() {
        let errorMenu = document.createElement('div');
        errorMenu.style.position = 'fixed';
        errorMenu.style.top = '50px';
        errorMenu.style.left = '50%';
        errorMenu.style.transform = 'translateX(-50%)';
        errorMenu.style.background = 'black';
        errorMenu.style.color = 'white';
        errorMenu.style.padding = '15px';
        errorMenu.style.borderRadius = '5px';
        errorMenu.style.zIndex = '10000';
        errorMenu.innerText = 'Error No4, No friends detected';

        let closeButton = document.createElement('button');
        closeButton.innerText = 'X';
        closeButton.style.marginLeft = '10px';
        closeButton.style.background = 'red';
        closeButton.style.color = 'white';
        closeButton.style.border = 'none';
        closeButton.style.cursor = 'pointer';

        closeButton.addEventListener('click', () => {
            errorMenu.remove();
        });

        errorMenu.appendChild(closeButton);
        document.body.appendChild(errorMenu);
    }

})();