Auto leveling - discord.com

Bare bone tool to auto level up on Discord servers, send messages automatically

当前为 2025-06-30 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Auto leveling - discord.com
// @namespace   https://github.com/Thibb1
// @match       https://*.discord.com/*
// @grant       none
// @version     1.1
// @author      Thibb1
// @description Bare bone tool to auto level up on Discord servers, send messages automatically
// @require     https://cdn.jsdelivr.net/npm/[email protected]/dist/lil-gui.umd.min.js
// @license     GPL
// @run-at      document-start
// ==/UserScript==


(function() {
  'use strict';
  function getToken() {
    window.dispatchEvent(new Event('beforeunload'));
    const LS = document.body.appendChild(document.createElement('iframe')).contentWindow.localStorage;
    return JSON.parse(LS.token);
  }

  let __localStorage = localStorage;
  let token = getToken();
  let lastMessageId = null;

  const gui = new lil.GUI();

  const settings = {
    autoSendText: false,
    autoRemoveLast: true,
    randomText: true,
    myString: 'hello',
    autoInterval: 60,
    randomTextLen: 5,
    testSendText: sendText
  };
  gui.add(settings, 'autoSendText');
  gui.add(settings, 'autoRemoveLast');
  gui.add(settings, 'randomText');
  gui.add(settings, 'myString');
  gui.add(settings, 'randomTextLen', 1, 25, 1);

  function autoSend() {
    if (!settings.autoSendText) return;
    sendText();
  }

  async function discordApi(method, route, body) {
    return await fetch(route, {
      method,
      headers: {
        "Content-Type": "application/json",
        "Authorization": token,
      },
      ...(body != null && { body: JSON.stringify(body) })
    });
  }

  async function sendText() {
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    let randomString = '';
    for (let i = 0; i < settings.randomTextLen; i++) {
      randomString += characters.charAt(Math.floor(Math.random() * characters.length));
    }
    const text = settings.randomText ? randomString : settings.myString;
    const channelStore = JSON.parse(__localStorage.getItem("SelectedChannelStore"));
    const channelId = channelStore.selectedChannelId;
    if (settings.autoRemoveLast && lastMessageId) {
      await discordApi('DELETE', `/api/v9/channels/${channelId}/messages/${lastMessageId}`)
        .then(response => {
          if (!response.ok) {
            console.error('Error deleting message:', response.statusText);
          }
        })
        .catch(error => {
          console.error('Error deleting message:', error);
        });
    }
    await discordApi('POST', `/api/v9/channels/${channelId}/messages`, { content: text, tts: false })
      .then(response => {
        if (!response.ok) {
          console.error('Error sending message:', response.statusText);
        } else {
          response.json().then(data => {lastMessageId = data.id; });
        }
      })
      .catch(error => {
        console.error('Error sending message:', error);
      });
  }

  let autoSendInterval;
  function startAutoSend() {
    if (autoSendInterval) {
      clearInterval(autoSendInterval);
    }
    if (settings.autoInterval > 0) {
      autoSendInterval = setInterval(autoSend, settings.autoInterval * 1000);
    }
  }
  gui.add(settings, 'autoInterval', 0, 120, 5).onChange(startAutoSend);
  gui.add(settings, 'testSendText');
  startAutoSend();
})();