下载知网硕博士论文pdf版

caj浏览器自带的文本复制功能太糟糕了,和常用的福昕阅读器没法比,但是对于硕博士论文cnki不提供pdf的下载链接

在chrome浏览器按F12进入控制台,粘贴一下代码然后回车

var allLis, thisLi, newLi, aPDF, bPDF, allLinks, thisLink, pageType, pfType, myurl, i;
var pageType = true;
var pfType = true;
var myurl = window.location.href;

allLinks = document.evaluate(
    '//a[@href]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

allLis = document.evaluate(
    "//li[@class]",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

if (myurl.indexOf("detail.aspx") != -1) {
    pageType = false;
} //false 为详情页面
if (document.title.indexOf(" - 中国知网") != -1) {
    pfType = false;
} //false 为新平台

if ((pfType === true) & (pageType === false)) {
    for (var i = 0; i < allLis.snapshotLength; i++) {
        thisLi = allLis.snapshotItem(i);
        if (thisLi.getAttribute("class").indexOf("readol") != -1) {
            newLi = document.createElement('li');
            newLi.setAttribute("class", "pdf");
            aPDF = '+ thisLi.firstChild.href.replace("&dflag=readonline", "&dflag=pdfdown") + '">PDF下载';
            newLi.innerHTML = aPDF;
            thisLi.parentNode.insertBefore(newLi, thisLi.nextSibling);
        }
    }
}

if ((pfType === false) & (pageType === false)) {
    for (var i = 0; i < allLinks.snapshotLength; i++) {
        thisLink = allLinks.snapshotItem(i);
        if (thisLink.href && thisLink.href.indexOf("download.aspx?filename=") != -1 && thisLink.innerHTML.indexOf("整本") != -1) {
            thisLink.innerHTML = thisLink.innerHTML.replace("整本", "CAJ");
            bPDF = thisLink.href;
        }
        if (thisLink.href && thisLink.href.indexOf("download.aspx?filename=") != -1 && thisLink.innerHTML.indexOf("分页") != -1) {
            thisLink.innerHTML = thisLink.innerHTML.replace("分页", "PDF");
            thisLink.href = bPDF.replace("nhdown", "pdfdown");
        }
    }
}

if (pageType === true) {
    for (var i = 0; i < allLinks.snapshotLength; i++) {
        thisLink = allLinks.snapshotItem(i);
        if (thisLink.href && thisLink.href.indexOf("download.aspx?filename=") != -1 && thisLink.href.indexOf("&dflag") == -1) {
            thisLink.href = thisLink.href + "&dflag=pdfdown";
        }
        if (thisLink.href && thisLink.href.indexOf("download.aspx?filename=") != -1 && thisLink.href.indexOf("&dflag=nhdown") != -1) {
            thisLink.href = thisLink.href.replace("nhdown", "pdfdown");
        }
    }
}

你可能感兴趣的:(代码改变生活)