Greasy Fork

Greasy Fork is available in English.

OP.GG 自动点击录制

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

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

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

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

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

您需要先安装一个扩展,例如 篡改猴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.2
// @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';

    // 創建一個觀察者實例來監視 DOM 變化
    const observer = new MutationObserver((mutationsList) => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList') {
                clickButton(); // 發現 DOM 變化後,調用點擊函數
            }
        }
    });

    // 配置觀察選項
    const config = {
        childList: true,
        subtree: true // 觀察子節點的變化
    };

    // 觀察整個 document.body
    observer.observe(document.body, config);

    // 定期檢查頁面內容
    setInterval(clickButton, 2000);

    // 檢查是否存在錄制按鈕,並點擊
    function clickButton() {
        const buttons = document.querySelectorAll('button'); // 查找所有按鈕
        buttons.forEach(button => {
            const buttonText = button.textContent.trim(); // 獲取按鈕的文本內容

            if (buttonText === "錄製") {
                console.log("點擊錄製按鈕");
                button.click();
            }
        });
    }

    // 初始運行一次
    clickButton();
})();