Greasy Fork is available in English.

【书友互助】读秀超星龙岩全国图书馆参考联盟,直接下载PDF文件,绝大部分有目录书签。

全方位助力您下载书籍,支持平台逐步扩展中...

// ==UserScript==
// @name              【书友互助】读秀超星龙岩全国图书馆参考联盟,直接下载PDF文件,绝大部分有目录书签。
// @namespace         http://syhz.getpdf.online
// @version           2.0.0
// @description       全方位助力您下载书籍,支持平台逐步扩展中...
// @include			*search*
// @include			*bookDetail.jsp?*
// @include			*advsearch*
// @include			*book.do?go=guide*
// @include			*book.do?go=showmorelib*
// @include			*searchEBook*
// @include			*www.duxiu.com*
// @include			*img.duxiu.com*
// @include			*book.douban.com*
// @include			*product.dangdang.com*
// @include			*kongfz.com*
// @copyright		houge
// @grant			none
// ==/UserScript==
//获取当前网页地址
var myurl = window.location.href;
//定义统一的样式
var mystyle = "font-family:Verdana;color:red;font-size:15px;font-weight:bold;text-align:center;margin-top:5px;margin-bottom:5px;text-decoration:none;";
var app = {
    run: function() {
        processUCDSRList();
        processUCDSR();
        processDouban();
        processDangDang();
        processKongFZ();
    }
};
function processKongFZ() {
    var id = null;
    if (myurl.match(/item\.kongfz\.com\/book\/\d+\.html/)) {
        id=isbn;
    }
    else if (myurl.match(/book\.kongfz\.com\/\d+\/\d+/)){
        id=DETAIL.isbn;
    }

    if (id && id.length >= 10){
        document.querySelector("h1").appendChild(createImageLink(false,id,null));
    }
}

function processDangDang() {
    if (myurl.match(/product\.dangdang\.com\/\d+\.html/)) {
        var detail = document.getElementById("detail_describe").innerHTML;
        if (detail) {
            var isbn = detail.match(/(\d{12}[\dxX])/)[1];
            if (isbn.length >= 10) {
                document.querySelector("h1").insertBefore(createImageLink(false,isbn,"position:relative;top:3px;"),document.querySelector("h1").childNodes[0]);
            }
        }
    }
}
function processDouban() {
    if (myurl.match(/douban\.com\/subject\/\d+\//)) {
        var metas = document.querySelectorAll("meta[property='book:isbn']");
        if (metas.length == 1) {
            var isbn = metas[0].getAttribute("content");
                document.querySelector("h1").insertBefore(createImageLink(false,isbn,null),document.querySelector("h1").childNodes[2]);
        }
    }
}
function processUCDSRList() {
    if (myurl.indexOf("search?") != -1) {
        var tables = document.getElementsByClassName("book1");
        for (var i = 0; i < tables.length; i++) {
            var table = tables[i];
            var dxid = document.getElementById("dxid"+i).getAttribute('value');
            var newTr = table.insertRow(table.rows.length);
            var newTd0 = newTr.insertCell(0);
            var newTd1 = newTr.insertCell(1);
            var newTd2 = newTr.insertCell(2);
            newTd1.align = "center";
            newTd1.appendChild(createTextLink(false,dxid));
            newTd1.appendChild(createImageLink(false,dxid,null));
            clearP(table.rows[0]);
        }
    }
}
function clearP(tr){
    var ps = tr.querySelectorAll("p");
    for(var i=ps.length-1;i>=0;i--){
        tr.removeChild(ps[i])
    }
    setTimeout(clearP, 1000,tr);
}

function processUCDSR() {
    if (myurl.indexOf("bookDetail.jsp?") != -1 && myurl.indexOf("/views/specific/") != -1) {
        var ssid = document.body.innerHTML.match(/dxid=(\d{12})/)[1];
        console.log(ssid);
        document.querySelector(".tubookimg").appendChild(createTextLink(true,ssid));
        document.querySelector(".tubookimg").appendChild(createImageLink(true,ssid,null));
    }
}

function buildUrl(searchKey) {
        return "https://syhz.getpdfnow.com/?_k=gf2023&key="+searchKey;
}

function createTextLink(withP,id) {
    var ssNode = document.createElement("p");
    ssNode.innerHTML = id;

    var aLink = document.createElement("a");
    aLink.href = buildUrl(id);
    aLink.target = "_blank";
    aLink.style = mystyle;
    aLink.innerHTML = id;

    return withP?wrapP(aLink):aLink;
}

function createImageLink(withP,id,aCss) {
    var stockNode = document.createElement("img");
    stockNode.src = "//stock.getpdfnow.com/Image.ashx?id=" + (id||"");
    stockNode.style = "display: inline;";

    var csgbutton = document.createElement("a");
    csgbutton.href = buildUrl(id);
    csgbutton.target = "_blank";
    csgbutton.appendChild(stockNode);
    if (aCss){
        csgbutton.style = aCss;
    }
    return withP?wrapP(csgbutton):csgbutton;

}
function wrapP(node){
    var p = document.createElement("p");
    p.style = "text-align:center;margin-top: 4px;";
    p.appendChild(node);
    return p;
}


try {
    app.run();
} catch(e) {
    console.log(e);
}