Custom Bilibili Auto Follow/Unfollow

A script to automatically follow/unfollow on Bilibili with a start/pause button

当前为 2024-08-24 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Custom Bilibili Auto Follow/Unfollow
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  A script to automatically follow/unfollow on Bilibili with a start/pause button
// @author       Larch4
// @match        https://space.bilibili.com/401742377
// @grant        none
// @license      GNU Affero General Public License v3.0
// ==/UserScript==

(function() {
        'use strict';
    
        let intervalId = null;
        let isRunning = false;
    
        // 创建控制面板
        const panel = document.createElement('div');
        panel.style.position = 'fixed';
        panel.style.bottom = '10px';
        panel.style.right = '10px';
        panel.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
        panel.style.color = '#fff';
        panel.style.padding = '10px';
        panel.style.zIndex = '10000';
        panel.innerHTML = `
            <button id="toggleButton">开始</button>
        `;
        document.body.appendChild(panel);
    
        const toggleButton = document.getElementById('toggleButton');
    
        // 启动或暂停脚本
        toggleButton.addEventListener('click', function() {
            if (isRunning) {
                clearInterval(intervalId);
                toggleButton.textContent = '开始';
            } else {
                startAutoFollowUnfollow();
                toggleButton.textContent = '暂停';
            }
            isRunning = !isRunning;
        });
    
        // 你现有的功能代码
        function O(number) {
            if (number == 1) {
                document.getElementsByClassName("be-dropdown-item")[1].click();
            } else {
                document.getElementsByClassName("h-f-btn h-follow")[0].click();
            }
        }
    
        function startAutoFollowUnfollow() {
            let x = 0;
            intervalId = setInterval(() => {
                if (x == 1) {
                    x = 0;
                } else {
                    x = 1;
                }
                setTimeout(() => {
                    O(x);
                }, 1000);
            }, 3000);
        }
    })();