Toggle Menu for JS

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);
})();