[Brick-Kill] Request Accepter

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

目前為 2024-07-08 提交的版本,檢視 最新版本

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

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

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

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

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

})();