Toggle Menu for JS

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

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

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