Toggle Menu for JS

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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