DLsite自动复制RJ号

打开DLsite的作品网址时自动复制RJ号

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey 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 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.

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

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

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         DLsite自动复制RJ号
// @version      1.01
// @description  打开DLsite的作品网址时自动复制RJ号
// @author       LC2808
// @match        https://www.dlsite.com/maniax/work/=/product_id/*
// @namespace https://greasyfork.org/users/1284881
// ==/UserScript==

(function() {
    'use strict';

    var currentURL = window.location.href;

    var regex = /\/(RJ\d+)\.html/;
    var match = currentURL.match(regex);

    if (match && match.length > 1) {
        var productCode = match[1];

        navigator.clipboard.writeText(productCode).then(function() {
            console.log('Copied RJ code to clipboard: ' + productCode);
        }, function(err) {
            console.error('Unable to copy RJ code to clipboard: ', err);
        });
    } else {
        console.log('No RJ code found in URL.');
    }
})();