vrchat one-time code

使用按鈕複製Gmail內的vrchat one-time code

Stan na 01-10-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         vrchat one-time code
// @version      1.4
// @description  使用按鈕複製Gmail內的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';

    const delay = 2000; // 2秒延遲載入按鈕, 沒按鈕的話就加大數字

    function generateSelector(elementId) {
        return `#\\${elementId} > div:nth-child(2) > p:nth-child(4) > b`;
    }

    function copyTextToClipboard(text) {
        const textArea = document.createElement("textarea");
        textArea.value = text;
        document.body.appendChild(textArea);
        textArea.select();
        document.execCommand("copy");
        document.body.removeChild(textArea);
    }

    function handleButtonClick() {
        const elements = document.querySelectorAll('.a3s.aiL');
        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();
                    copyTextToClipboard(textToCopy);
                }
            }
        });
    }

    function addButton() {
        const customButton = document.createElement('button');
        customButton.textContent = 'VRChat code';
        customButton.addEventListener('click', handleButtonClick);

        const buttonParent = document.querySelectorAll('.bGJ')[0];

        if (buttonParent) {
            buttonParent.appendChild(customButton);
        }
    }

    // 在頁面載入完成後執行
    window.addEventListener('load', () => {
        setTimeout(addButton, delay);
    });
})();