GC - Copy SDB Inventory

Adds a button to your SDB page above your items. When clicked it copies all the items on the current page.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GC - Copy SDB Inventory
// @namespace    http://tampermonkey.net/
// @version      1.1
// @author       AshyAsh
// @description  Adds a button to your SDB page above your items. When clicked it copies all the items on the current page.
// @match        https://www.grundos.cafe/safetydeposit/*
// @grant        GM_setClipboard
// @license      MIT   
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// ==/UserScript==

(function() {
    'use strict';

    // Function to add custom CSS
    function addCustomCSS() {
        const css = `
            .custom-copy-button {
              background-color: #ACE1AF;
              border: 2px solid #6ECB73;
              padding: 5px 10px 15px 10px;
              margin: 10px;
              cursor: pointer;
              width: 85%;
              font-weight: 600;
              letter-spacing: 2px;
              text-transform: uppercase;
            }

            .custom-copy-button:hover {
                background-color: #AFADE1;
                letter-spacing: 3px;
                border: 2px solid #726FCA;
            }

            .custom-copy-button.copied {
                background-color: #03C03C;
                color: white;
                border: 2px solid #6ECB73;
            }
        `;

        const head = document.head || document.getElementsByTagName('head')[0];
        const style = document.createElement('style');
        style.type = 'text/css';
        style.appendChild(document.createTextNode(css));
        head.appendChild(style);
    }

    // Function to extract text and copy to clipboard
    function copyText() {
        let elements = document.querySelectorAll('.data.flex-column.small-gap.break strong');
        let textList = [];

        elements.forEach(element => {
            textList.push(element.textContent);
        });

        GM_setClipboard(textList.join("\n"));

        // Change button appearance upon successful copy
        copyButton.classList.add('copied');
        copyButton.textContent = 'Items Copied!';
    }

    // Add custom CSS to the page
    addCustomCSS();

    // Create and insert a button to trigger the copy function
    let copyButton = document.createElement('button');
    copyButton.textContent = 'Copy Inventory';
    copyButton.className = 'custom-copy-button';
    copyButton.addEventListener('click', function(event) {
        event.preventDefault(); // Prevent any default button behavior
        copyText();
    });

    // Select the target element to place the button above
    let targetElement = document.querySelector('.market_grid.sdb.margin-1');

    if (targetElement) {
        targetElement.parentNode.insertBefore(copyButton, targetElement);
    }
})();