OP.GG Auto Recorder

Automatically clicks "Record" buttons on OP.GG website

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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.6
// @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 buttons = document.querySelectorAll('button span');
            buttons.forEach(button => {
                if (button.textContent.trim() === '錄製') {
                    console.log("點擊錄製按鈕");
                    button.closest('button').click();
                }
            });
        }
    }
})();