Greasy Fork is available in English.

DLsite复制助手

快捷复制商品信息

Skript installieren?
Vom Ersteller vorgeschlagenes Skript

Ihnen könnte auch BiliBili视频批量举报 gefallen.

Skript installieren
// ==UserScript==
// @name         DLsite复制助手
// @namespace    https://www.dlsite.com
// @version      0.0.1
// @description  快捷复制商品信息
// @author       AAA
// @match        https://www.dlsite.com/*
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    // 从网址提取商品ID和标题的函数
    function extractProductID() {
        // 从URL中提取商品ID
        const productId = window.location.href.match(/\/RJ(\d+)\.html/)[1];

        // 将商品ID复制到剪贴板,并换行
        GM_setClipboard(`RJ${productId}\n`);

        console.log('商品ID已复制到剪贴板:\nRJ' + productId);
        // 显示简短通知
        showNotification('RJ号已复制到剪贴板');
    }

    // 提取标题的函数
    function extractTitle() {
        // 从HTML中提取标题
        const title = document.getElementById('work_name').innerText.trim();

        // 将标题复制到剪贴板,并换行
        GM_setClipboard(`${title}\n`);

        console.log('标题已复制到剪贴板:\n' + title);
        // 显示简短通知
        showNotification('标题已复制到剪贴板');
    }

    // 显示简短通知的函数
    function showNotification(message) {
        const notification = document.createElement('div');
        notification.textContent = message;
        notification.style.position = 'fixed';
        notification.style.top = '10px';
        notification.style.right = '10px';
        notification.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        notification.style.color = 'white';
        notification.style.padding = '5px 10px';
        notification.style.borderRadius = '5px';
        notification.style.zIndex = '9999';
        notification.style.animation = 'fadeout 3s forwards';

        document.body.appendChild(notification);

        setTimeout(function() {
            notification.remove();
        }, 3000);
    }

    // 检查当前URL是否与制作者资料页匹配的函数
    function isMakerProfilePage() {
        return window.location.href.includes('/maker_id/RG');

    }

    // 检查当前URL是否与商品页匹配的函数
    function isProductPage() {
        return window.location.href.includes('/product_id/RJ');

    }

    // 如果是商品页,创建提取商品ID的按钮
    function createProductIdButton() {
        const buttonContainer = document.createElement('div');
        buttonContainer.style.position = 'fixed';
        buttonContainer.style.top = '175px';
        buttonContainer.style.right = '310px';
        buttonContainer.style.zIndex = '9999';

        const extractButton = document.createElement('button');
        extractButton.textContent = '复制RJ号';
        extractButton.style.padding = '8px';
        extractButton.style.backgroundColor = '#4CAF50';
        extractButton.style.color = 'white';
        extractButton.style.border = 'none';
        extractButton.style.borderRadius = '5px';
        extractButton.style.cursor = 'pointer';
        extractButton.onclick = extractProductID;

        buttonContainer.appendChild(extractButton);
        document.body.appendChild(buttonContainer);
    }

    // 如果是商品页,创建提取标题的按钮
    function createTitleButton() {
        const buttonContainer = document.createElement('div');
        buttonContainer.style.position = 'fixed';
        buttonContainer.style.top = '175px';
        buttonContainer.style.right = '220px';
        buttonContainer.style.zIndex = '9999';

        const extractButton = document.createElement('button');
        extractButton.textContent = '复制标题';
        extractButton.style.padding = '8px';
        extractButton.style.backgroundColor = '#4CAF50';
        extractButton.style.color = 'white';
        extractButton.style.border = 'none';
        extractButton.style.borderRadius = '5px';
        extractButton.style.cursor = 'pointer';
        extractButton.onclick = extractTitle;

        buttonContainer.appendChild(extractButton);
        document.body.appendChild(buttonContainer);
    }

    // 根据页面类型执行操作的函数
    function performActions() {
        if (isMakerProfilePage()) {
           // deleteElements();
            addCopyButtons();
        } else if (isProductPage()) {
            createProductIdButton();
            createTitleButton();
        }
    }

    // 在作品列表中添加复制按钮
    function addCopyButtons() {
    let works = document.querySelectorAll('dd.work_name');
    works.forEach(work => {
        let link = work.querySelector('a');
        let rjNumber = "RJ" + link.href.match(/\/RJ(\d+)\.html/)[1];
        let title = link.title;
        let copyRJButton = document.createElement('button');
        copyRJButton.textContent = '复制RJ号';
        copyRJButton.style.display = 'none';
        copyRJButton.addEventListener('click', function() {
            GM_setClipboard(rjNumber);
            showNotification('RJ号已复制到剪贴板');
        });
        let copyTitleButton = document.createElement('button');
        copyTitleButton.textContent = '复制标题';
        copyTitleButton.style.display = 'none';
        copyTitleButton.addEventListener('click', function() {
            GM_setClipboard(title);
            showNotification('标题已复制到剪贴板');
        });
        work.appendChild(copyRJButton);
        work.appendChild(copyTitleButton);
        work.addEventListener('mouseover', function() {
            copyRJButton.style.display = 'inline-block';
            copyTitleButton.style.display = 'inline-block';
        });
        work.addEventListener('mouseout', function() {
            copyRJButton.style.display = 'none';
            copyTitleButton.style.display = 'none';
        });
    });
}

    // 页面加载时创建按钮或删除元素
    window.addEventListener('load', performActions);
})();