Background scr_run

4 button

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Background scr_run
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  4 button
// @author       umaimann
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const items = [
        { name: '𝙈𝙊𝙉𝙏𝘼𝙂𝙀𝙈 𝙎𝙀𝙉𝙏𝘼𝙍 - (𝙎𝙪𝙥𝙚𝙧 𝙎𝙡𝙤𝙬𝙚𝙙)', url: 'https://update.greasyfork.org/scripts/574925/Background%20scr_4.user.js' },
        { name: '𝙃𝙀𝘼𝙑𝙀𝙉𝙇𝙔 𝙅𝙐𝙈𝙋𝙎𝙏𝙔𝙇𝙀 - (𝙎𝙪𝙥𝙚𝙧 𝙎𝙡𝙤𝙬𝙚𝙙)', url: 'https://update.greasyfork.org/scripts/574924/Background%20scr_3.user.js' },
        { name: '𝙈𝙤𝙣𝙩𝙖𝙜𝙚𝙢 𝙔𝙪𝙠𝙞 - (𝙎𝙡𝙤𝙬𝙚𝙙)', url: 'https://update.greasyfork.org/scripts/574922/Background%20scr_copy_2.user.js' },
        { name: '𝙈𝙀𝙉𝙃𝙀𝙍𝘼 𝙁𝙐𝙉𝙆', url: 'https://update.greasyfork.org/scripts/574789/Background%20scr_copy.user.js' }
    ];

    const buttons = [];

    items.forEach((item, i) => {
        fetch(item.url)
            .then(res => {
                if (!res.ok) throw new Error('取得失敗');
                return res.text();
            })
            .then(text => {
                const btn = document.createElement('button');
                btn.textContent = item.name;
                btn.style.position = 'fixed';
                btn.style.top = (10 + i * 50) + 'px';
                btn.style.left = '10px';
                btn.style.zIndex = 9999;
                btn.style.padding = '8px';
                btn.style.background = 'lime';
                btn.style.border = '2px solid black';
                btn.style.fontSize = '12px';

                document.body.appendChild(btn);
                buttons.push(btn);

                btn.onclick = () => {
                    try {
                        const ta = document.createElement('textarea');
                        ta.value = text;
                        document.body.appendChild(ta);
                        ta.select();
                        const success = document.execCommand('copy');
                        document.body.removeChild(ta);

                        if (success) {
                            buttons.forEach(b => b.remove());
                            alert(item.name + ' をコピーしました!');
                        } else {
                            alert('コピー失敗(手動コピーして)');
                        }
                    } catch (e) {
                        alert('エラー: ' + e);
                    }
                };
            })
            .catch(e => console.error(e));
    });
})();