vrchat one-time code

複製vrchat one-time code

当前为 2023-09-16 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         vrchat one-time code
// @version      1.1
// @description  複製vrchat one-time code
// @author       BaconEgg
// @match        https://mail.google.com/mail/u/0/?tab=*
// @grant        none
// @namespace https://greasyfork.org/users/735944
// ==/UserScript==

(function() {
    'use strict';

    // 生成選擇器
    function generateSelector(elementId) {
        return `#\\${elementId} > div:nth-child(2) > p:nth-child(4) > b`;
    }

    const delay = 2000; // 延遲時間,例如2秒的延遲

    // 在頁面加載完成後執行
    setTimeout(() => {
        // 創建自定義按鈕
        const customButton = document.createElement('button');
        customButton.textContent = 'vrchat code';

        // 找到按鈕的父元素
        const buttonParent = document.querySelector("#gb > div.gb_ld.gb_fd.gb_rd.gb_Jc > div.gb_kd.gb_ud.gb_ze.gb_Me.gb_Re > div.gb_ce.gb_ae.bGJ");

        if (buttonParent) {
            // 將自定義按鈕插入到按鈕的父元素中
            buttonParent.appendChild(customButton);
        }

        // 添加按鈕點擊事件處理程序
        customButton.addEventListener('click', function() {
            // 查找具有 class "a3s aiL" 的元素
            const elements = document.querySelectorAll('.a3s.aiL');

            if (elements.length > 0) {
                // 遍歷匹配的元素並處理它們
                elements.forEach(function(element) {
                    const elementId = element.getAttribute('id');
                    if (elementId) {
                        const selector = generateSelector(elementId);
                        const element2 = document.querySelector(selector);
                        if (element2) {
                            // 複製元素的文本內容到剪貼板
                            const textToCopy = element2.textContent.trim();
                            const textArea = document.createElement("textarea");
                            textArea.value = textToCopy;
                            document.body.appendChild(textArea);
                            textArea.select();
                            document.execCommand("copy");
                            document.body.removeChild(textArea);
                        }
                    }
                });
            }
        });

    }, delay);
})();