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.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
    }
})();