Sukebei to Javlibrary

add link to Javlibrary

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Sukebei to Javlibrary
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  add link to Javlibrary
// @include      https://sukebei.nyaa.si/*
// @author       You
// @match        http://*/*
// @grant        https://sukebei.nyaa.si/
// @require      http://code.jquery.com/jquery-3.6.0.min.js
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    // Iterate over each row
    $('table tr').each(function() {
        // Find the second <td> element containing a <a> tag within the current row
        var secondTd = $(this).find('td:nth-child(2)').has('a');
        // Extract the text from the second <td> using the first regular expression

        //var regex = /[A-Za-z]+-\d+/;
        var regex = /T\d{2}-\d{3}|[A-Za-z]+-\d+/;
        var extractText = secondTd.text().match(regex);

        //console.log(extractText);

        if (extractText) {

            // Create an <a> tag and set its attributes
            var anchorTag = $('<a>', {
                href: 'https://www.javlibrary.com/en/vl_searchbyid.php?keyword=' + extractText[0],
            }).append($('<img>').attr({
                src: 'https://www.javlibrary.com/favicon.ico',
                width: 20,
                height: 20
            }));
            // Find the third <td> element within the current row and append the <a> tag
            $(this).find('td:nth-child(3)').append(anchorTag);
        }
    });
})();