[Brick-Kill] Request Accepter

Accepts the requests to join from 1 user if you're using Clan Botter.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// discord.gg/JjszyaD63A

// ==UserScript==
// @name         [Brick-Kill] Request Accepter
// @version      1.02
// @description  Accepts the requests to join from 1 user if you're using Clan Botter.
// @author       Spacekiller
// @match        *://www.brick-hill.com/*
// @icon         https://www.brick-hill.com/favicon.ico
// @license      MIT
// @namespace    bhrequestaccepter
// ==/UserScript==

(function() {
    'use strict';

    /*-    SETTINGS    -*/
    const config = {
        invite: {
            enabled: true, // Set to true to enable automatic invite accepting.
            interval: 1, // Interval in seconds between invite accept attempts.
            userId: "12345", // The user ID for the invite.
            clanId: "8000" // The clan ID to accept the request from.
        }
    };
    /*-                -*/

    function sendRequest(url, method, body) {
        const token = document.querySelector('input[name="_token"]').value;
        const requestBody = new FormData();
        for (const key in body) {
            requestBody.append(key, body[key]);
        }
        requestBody.append('_token', token);

        return fetch(url, {
            method: method,
            body: requestBody
        });
    }

    function handleInviteRequest() {
        if (!config.invite.enabled) return;
        const url = 'https://www.brick-hill.com/clan/edit';
        const body = {
            type: "pending_member",
            user_id: config.invite.userId,
            clan_id: config.invite.clanId,
            accept: "accept"
        };
        sendRequest(url, 'POST', body).then(() => {
            console.log('Invite accepted successfully.');
        }).catch((error) => {
            console.error('Error accepting invite:', error);
        });

        const nextExecution = Date.now() + config.invite.interval * 1000;
        setTimeout(handleInviteRequest, nextExecution - Date.now());
    }

    handleInviteRequest();

})();