Toggle Menu for JS

Toggle menu (三つだけ) - ボタンで ", ', ` をコピー

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         Toggle Menu for JS
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Toggle menu (三つだけ) - ボタンで ", ', ` をコピー
// @author       umaimann
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    // 既存のGUIがあれば削除
    const existing = document.getElementById('copy-quote-gui');
    if (existing) existing.remove();

    // GUI作成
    const gui = document.createElement('div');
    gui.id = 'copy-quote-gui';
    Object.assign(gui.style, {
        position: 'fixed',
        top: '20px',
        right: '20px',
        padding: '10px',
        background: '#f0f0f0',
        border: '1px solid #ccc',
        borderRadius: '8px',
        boxShadow: '0 2px 6px rgba(0,0,0,0.2)',
        zIndex: 9999,
        fontFamily: 'sans-serif',
        display: 'flex',
        flexDirection: 'column',
        gap: '8px',
        alignItems: 'center'
    });

    // コピー用文字
    const chars = ['"', "'", '`'];
    const charContainer = document.createElement('div');
    charContainer.style.display = 'flex';
    charContainer.style.gap = '5px';

    chars.forEach(c => {
        const btn = document.createElement('button');
        btn.textContent = c;
        Object.assign(btn.style, {
            padding: '5px 10px',
            cursor: 'pointer'
        });
        btn.onclick = () => {
            navigator.clipboard.writeText(c).then(() => {
                const original = btn.textContent;
                btn.textContent = 'コピー完了 ✔';
                setTimeout(() => btn.textContent = original, 1000);
            });
        };
        charContainer.appendChild(btn);
    });

    gui.appendChild(charContainer);
    document.body.appendChild(gui);
})();