Greasy Fork is available in English.

Refrag Auto Join Server

Automatically joins Refrag server when it starts (opens steam:// link)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Refrag Auto Join Server
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Automatically joins Refrag server when it starts (opens steam:// link)
// @author       Claude
// @match        https://play.refrag.gg/*
// @grant        none
// @license      MIT
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';

    const CHECK_INTERVAL_MS = 2000;

    let joined = false;
    let statusBox;
    let intervalId;

    function createStatusBox() {
        const box = document.createElement('div');
        box.id = 'refrag-autojoin-status';
        Object.assign(box.style, {
            position:     'fixed',
            bottom:       '18px',
            right:        '18px',
            zIndex:       '99999',
            background:   '#1a1a2e',
            color:        '#e0e0e0',
            border:       '1px solid #4f46e5',
            borderRadius: '10px',
            padding:      '10px 16px',
            fontSize:     '13px',
            fontFamily:   'monospace',
            boxShadow:    '0 4px 20px rgba(79,70,229,0.4)',
            minWidth:     '240px',
            lineHeight:   '1.6',
        });
        document.body.appendChild(box);
        return box;
    }

    function setStatus(msg, color = '#a5b4fc') {
        if (!statusBox) statusBox = createStatusBox();
        statusBox.innerHTML =
            `<b style="color:#818cf8">🎮 Refrag AutoJoin</b><br>` +
            `<span style="color:${color}">${msg}</span>`;
    }

    function findSteamLink() {
        const anchor = document.querySelector('a[href^="steam://connect/"]');
        if (anchor) return anchor.href;
        return null;
    }

    function doJoin(url) {
        joined = true;
        clearInterval(intervalId);
        console.log('[Refrag AutoJoin] Opening:', url);
        setStatus(`✅ Joined!<br><small style="word-break:break-all">${url}</small>`, '#4ade80');
        window.location.href = url;
    }

    function tick() {
        if (joined) return;
        const link = findSteamLink();
        if (!link) {
            setStatus('🔴 Server offline – waiting...', '#f87171');
            return;
        }
        doJoin(link);
    }

    setStatus('⚡ Script active – monitoring...', '#a5b4fc');
    intervalId = setInterval(tick, CHECK_INTERVAL_MS);

})();