Greasy Fork

Greasy Fork is available in English.

OP.GG 自动点击录制

自动点击 OP.GG 网站上的「录制」按钮

当前为 2024-09-14 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         OP.GG Auto Recorder
// @name:zh-TW   OP.GG 自動點擊錄製
// @name:zh-CN   OP.GG 自动点击录制
// @namespace    https://www.youtube.com/c/ScottDoha
// @version      1.5
// @description  Automatically clicks "Record" buttons on OP.GG website
// @description:zh-TW 自動點擊 OP.GG 網站上的「錄製」按鈕
// @description:zh-CN 自动点击 OP.GG 网站上的「录制」按钮
// @author       Scott
// @match        *://*.op.gg/summoners/*
// @grant        none
// @license MIT
// ==/UserScript==


(function() {
    'use strict';

    // 获取脚本启用状态,默认为启用状态
    const isEnabled = JSON.parse(localStorage.getItem('autoRecorderEnabled') || 'true');

    // 页面加载完成后插入开关按钮
    window.addEventListener('load', function() {
        const serviceMenu = document.querySelector('.ServiceMenu-module_service-menu__cUv5k');
        if (serviceMenu) {
            const toggleButton = document.createElement('a');
            toggleButton.textContent = isEnabled ? 'Disable Auto Recorder' : 'Enable Auto Recorder';
            toggleButton.style.cursor = 'pointer';
            toggleButton.style.marginLeft = '10px';
            toggleButton.style.color = '#fff';
            toggleButton.style.backgroundColor = '#007bff';
            toggleButton.style.padding = '5px 10px';
            toggleButton.style.borderRadius = '5px';
            serviceMenu.appendChild(toggleButton);

            // 点击开关按钮时切换状态
            toggleButton.addEventListener('click', function() {
                const currentState = JSON.parse(localStorage.getItem('autoRecorderEnabled') || 'true');
                const newState = !currentState;
                localStorage.setItem('autoRecorderEnabled', JSON.stringify(newState));
                toggleButton.textContent = newState ? 'Disable Auto Recorder' : 'Enable Auto Recorder';
                location.reload(); // 切换后刷新页面
            });
        }

        // 如果脚本启用,开始执行录制按钮检测
        if (isEnabled) {
            startAutoRecorder();
        }
    });

    // 自动录制功能
    function startAutoRecorder() {
        // 每60秒刷新页面
        setInterval(function() {
            location.reload();
        }, 60000); // 60000ms = 60s

        // 页面加载完成后检查按钮
        window.addEventListener('load', function() {
            clickRecordButton(); // 页面加载时检查按钮
        });

        // 定期检查录制按钮
        setInterval(clickRecordButton, 2000); // 每2秒检查一次

        // 检查是否存在录制按钮,并点击
        function clickRecordButton() {
            // 查找按钮,确保查找到含有“錄製”文字的按钮
            const recordButton = document.querySelector('button span');
            if (recordButton && recordButton.textContent.trim() === '錄製') {
                console.log("點擊錄製按鈕");
                // 找到按钮后,点击它的父级button元素
                recordButton.closest('button').click();
            } else {
                console.log("未找到錄製按鈕");
            }
        }
    }
})();