BrickHL

Raw server info copier for BrickHL (headless brick hill client)

当前为 2022-05-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         BrickHL
// @namespace    http://tampermonkey.net/
// @description  Raw server info copier for BrickHL (headless brick hill client)
// @version      0.1
// @author       Yek
// @match        https://*.brick-hill.com/play/*
// @run-at       document-idle
// @grant        none
// @license      MIT
// ==/UserScript==
(async function(){
    const node = $.parseHTML($('#setpage-v')[0].__vue_app__._component.template)[0]
    const stuff = {
        address: node.getAttribute("set-ip"),
        id: node.getAttribute(":set-id"),
        port: node.getAttribute("set-port")
    }

    setTimeout(async function timeOut(){
        const playButton = document.getElementsByClassName('play-button')[0];
        if (!playButton) {
            setTimeout(timeOut,100)
            return
        }
        const copyButton = playButton.cloneNode();

        //copyButton.className = copyButton.className.replace('play-button ', '')
        copyButton.className = "blue mb-20-no-mobile play-button"
        copyButton.textContent = "BRICK HL";
        copyButton.style.fontSize = "20px"
        copyButton.onclick = () => {
            $.ajax({url:window.BH.apiUrl('v1/auth/generateToken?set='.concat(stuff.id)),xhrFields:{withCredentials:true}})
                .then(function(data){
                    //navigator.clipboard.writeText(data.token).then(()=>{alert("Copied token.")})
                    navigator.clipboard.writeText("TOKEN:" + data.token + ";ID:" + stuff.id + ";PORT:" + stuff.port + ";IP:" + atob(stuff.address.split("").reverse().join("")) + ";").then(()=>{alert("TOKEN: " + data.token + "\nGAME ID: " + stuff.id + "\nIP: " + atob(stuff.address.split("").reverse().join("")) + "\nPORT: " + stuff.port + "\n\nData copied to clipboard!")})
                });
        }
        playButton.parentNode.append(copyButton);
    },100)
})();