DLsite自动复制RJ号

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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