Disboard Bypass Redirect

Bypasses Disboard's join button redirect, by fetching the Discord invite directly from their API. Only works on the server page, not home page.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Disboard Bypass Redirect
// @namespace    https://spin.rip/
// @version      2025-03-04
// @description  Bypasses Disboard's join button redirect, by fetching the Discord invite directly from their API. Only works on the server page, not home page.
// @author       Spinfal
// @match        https://disboard.org/server/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=disboard.org
// @grant        none
// @license      AGPL-3.0 License
// ==/UserScript==

(function() {
    'use strict';

    window.msTimeout = 0;
    window.onload = () => {
        setTimeout(() => {
            const csrfToken = document.querySelector('[name="csrf-token"]')?.content;
            const disboardServerId = location.pathname.split("/").pop();

            if (!csrfToken) {
                window.msTimeout = 2000; // apply a timeout to ensure everything fully loads
                return alert("No CSRF Token was found. Try reloading the page.");
            } else {
                console.log(`CSRF Token found: ${csrfToken}`);
                console.log("Fetching invite now!");
                fetch(`https://disboard.org/site/get-invite/${disboardServerId}`, {
                    "headers": {
                        "accept": "*/*",
                        "accept-language": "en-US,en;q=0.6",
                        "priority": "u=1, i",
                        "x-csrf-token": csrfToken
                    },
                    "referrer": `https://disboard.org/server/join/${disboardServerId}`,
                    "referrerPolicy": "strict-origin-when-cross-origin",
                    "body": null,
                    "method": "POST",
                    "mode": "cors",
                    "credentials": "include"
                }).then(response => response.json()).then(response => {
                    const joinBtn = document.querySelector(`[data-id="${disboardServerId}"]`);
                    joinBtn.href = response;
                    joinBtn.removeAttribute("onclick");
                    joinBtn.innerText = "SKIP THE BULLSHIT";
                }).catch(error => new Error(error));
            }
        }, window.msTimeout);
    }
})();