Roblox Friend Remover

Remove all of your friends on Roblox

// ==UserScript==
// @name         Roblox Friend Remover
// @namespace    https://spin.rip/
// @version      2025-03-08
// @description  Remove all of your friends on Roblox
// @author       Spinfal
// @match        https://www.roblox.com/users/*/profile
// @icon         https://www.google.com/s2/favicons?domain=roblox.com
// @grant        none
// @license      AGPL-3.0 License
// ==/UserScript==

(async function() {
    'use strict';

    const userID = Roblox?.CurrentUser?.userId || prompt('Your Roblox user ID (MUST be yours):');
    if (userID) {
        if (confirm('Remove all friends?')) {
            const token = Roblox?.XsrfToken?.getToken() || prompt('If you have your own CSRF token, provide it here:');
            if (!token) return alert('No CSRF token was available. Try reloading the page.');
            alert('CSRF Token (auth) set to: ' + token);
            fetch(`https://friends.roblox.com/v1/users/${userID}/friends?sortOrder=Desc`).then(res => res.json()).then(res => {
                res.data.forEach(user => {
                    fetch(`https://friends.roblox.com/v1/users/${user.id}/unfriend`, {
                        "headers": {
                            "x-csrf-token": token
                        },
                        "method": "POST"
                    });
                });
            }).catch(e => {
                alert('An error has occurred. Check the DevConsole for more info.');
                console.error();
            });
        }
    } else {
        alert("No Roblox user ID was available. Try reloading the page.");
    }
})();