2023获取ss号

获取SS号

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         2023获取ss号
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  获取SS号
// @author
// @match        http://book.gzlib.org/views/*
// @match        http://www.ucdrs.superlib.net/*
// @match        http://book.ucdrs.superlib.net/views/*
// @match        https://book.duxiu.com/bookDetail.jsp?*
// @grant        GM_xmlhttpRequest
// @license      吾爱破解
// ==/UserScript==


setTimeout(function () {
    var lt_url = window.location.href;
    var img_herf;
    try {
        img_herf = document.getElementsByClassName('testimg')[0].getElementsByTagName('a')[0].getAttribute('href');
    } catch {
        try{
            img_herf = document.getElementsByClassName('link')[0].getElementsByTagName('a')[0].getAttribute('href');
        }
        catch {
            img_herf = document.getElementsByClassName('bnt_content')[0].getElementsByTagName('a')[0].getAttribute('href');
        }
    }
    var reg = /\/.*?(?=')/;
    var url;
    if (lt_url.indexOf("ucdrs") !== -1) {
        url = "http://book.ucdrs.superlib.net/" + img_herf.match(reg);
    } else if (lt_url.indexOf("gzlib") !== -1) {
        url = "http://book.gzlib.org/" + img_herf.match(reg);
    } else if (lt_url.indexOf("duxiu") !== -1) {
        img_herf = document.getElementsByClassName('bnt_content')[0].getElementsByTagName('a')[0].getAttribute('href');
        url = "http://book.duxiu.com/" + img_herf.match(reg);
    }
    GM_xmlhttpRequest({
        url: url,
        method: "GET",
        onload: function (xhr) {
            var ssurl = xhr.finalUrl;
            var ssreg = /\d{8}(?=\/)/;
            var ssno = ssurl.match(ssreg);
            window.bookssno = ssno;
            sentback(ssno);
        }
    });

    function sentback(ssno) {
        const online = document.getElementsByClassName("tubookimg")[0];
        const ss_div = document.createElement('div');
        ss_div.className = 'ssno';
        ss_div.innerHTML = '<span><font color="blue" size="16">SS:' + window.bookssno + '</font></span>';

        if (online==undefined){
            const online1 = document.getElementsByClassName("card_pic leftF")[0];
            online1.insertAdjacentElement('afterend', ss_div);
        }else{
            online.insertAdjacentElement('afterend', ss_div);
        }
    }
    // Your code here...
}, 1000);