florr.io | Shows current server you are in & Easily switch server

Read title

目前為 2023-04-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         florr.io | Shows current server you are in & Easily switch server
// @namespace    https://github.com/Samer-Kizi
// @version      1.0.12
// @description  Read title
// @author       sk
// @match        https://florr.io/*
// @grant        unsafeWindow
// @license      MIT
// ==/UserScript==
var totalServers = 14 - 1,
    version = "1.0.12",
    pos = "-100px"

let url;
const nativeWebSocket = unsafeWindow.WebSocket;
unsafeWindow.WebSocket = function(...args) {
    const socket = new nativeWebSocket(...args);
    url = socket.url
    return socket;
};

let cp6 = unsafeWindow.cp6
document.documentElement.addEventListener("keydown", function() {
    if (event.keyCode === 9) getServerId() // https://www.toptal.com/developers/keycode
    else if (event.keyCode === 32 && event.shiftKey && event.ctrlKey) changeServer()
});

var doc = document.createElement('div')
doc.style = `
    width: 700px;
    height: auto;
    background: #DB5A5A;
    z-index: 1;
    position: relative;
    border-radius: 5px;
    border: 4.5px solid #B14949;
    margin: 0 auto;
    color: white;
    text-align: center;
    font-family: 'Ubuntu';
    padding: 10px;
    text-shadow: rgb(0 0 0) 2px 0px 0px, rgb(0 0 0) 1.75517px 0.958851px 0px, rgb(0 0 0) 1.0806px 1.68294px 0px, rgb(0 0 0) 0.141474px 1.99499px 0px, rgb(0 0 0) -0.832294px 1.81859px 0px, rgb(0 0 0) -1.60229px 1.19694px 0px, rgb(0 0 0) -1.97998px 0.28224px 0px, rgb(0 0 0) -1.87291px -0.701566px 0px, rgb(0 0 0) -1.30729px -1.5136px 0px, rgb(0 0 0) -0.421592px -1.95506px 0px, rgb(0 0 0) 0.567324px -1.91785px 0px, rgb(0 0 0) 1.41734px -1.41108px 0px, rgb(0 0 0) 1.92034px -0.558831px 0px;
    top: ${pos};
    cursor: pointer;
    transition: all 1s ease-in-out;
`
doc.onclick = function() {
    doc.innerHTML = `Getting all server codes...<br>All server codes will be shown in Dev Tool Console (F12)`
    let servers1 = [];
    let count = 0;
    for (let i = 0; i <= totalServers; i++) {
        fetch("https://api.n.m28.io/endpoint/florrio-map-" + i + "-green/findEach/").then((response) => response.json()).then((data) => {
            servers1[i] = {
                "NA": data.servers['vultr-miami'].id,
                "EU": data.servers['vultr-frankfurt'].id,
                "AS": data.servers['vultr-tokyo'].id
            };
            count++;
            if (count == totalServers) {
                console.table(servers1);
                doc.innerHTML = `Done!`
                setTimeout(function() {
                    doc.innerHTML = `Connected to ${regionName} ${mapName}<br>${url.slice(6,-1)} - <a style="color:#2BFFA3">v${version}</a>`
                }, 3000)
            }
        });
    }
}
document.querySelector('body').appendChild(doc)
var servers = [],
    mapName,
    regionName,
    codeA = [],
    code;
for (let i = 0; i <= totalServers; i++) {
    fetch("https://api.n.m28.io/endpoint/florrio-map-" + i + "-green/findEach/").then((response) => response.json()).then((data) => {
        servers[i] = `${data.servers["vultr-miami"].id} ${data.servers["vultr-frankfurt"].id} ${data.servers["vultr-tokyo"].id}`
    })
};

function getServerId() {
    var wssUrl = url.slice(6, 9)
    servers.forEach(function callback(x, index) {
        if (x.includes(wssUrl)) {
            mapName = "MAP" + index
            codeA = x.split(" ")
            if (wssUrl == codeA[0]) regionName = "NA"
            else if (wssUrl == codeA[1]) regionName = "EU"
            else if (wssUrl == codeA[2]) regionName = "AS"
        }
    });
    doc.innerHTML = `Connected to ${regionName} ${mapName}<br>${url.slice(6,-1)} - <a style="color:#2BFFA3">v${version}</a>`
    doc.style.top = doc.style.top === '0px' ? pos : '0px'
}

function changeServer() {
    code = prompt('Input server name: na/eu/as?')
    if (code.toLowerCase() == 'na') cp6.forceServerID(servers[1].split(" ")[0])
    else if (code.toLowerCase() == 'eu') cp6.forceServerID(servers[1].split(" ")[1])
    else if (code.toLowerCase() == 'as') cp6.forceServerID(servers[1].split(" ")[2])
}

var urlA = []
setInterval(function() {
    urlA.unshift(url)
    if (urlA.length > 2) urlA.splice(2)
    if (urlA.at(-1) != urlA[0]) {
        getServerId()
        doc.style.top = '0px'
        setTimeout(function() {
            doc.style.top = pos
        }, 3000)
    }
}, 1000)

QingJ © 2025

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