知网下载助手

解析CNKI论文PDF格式下载地址,论文搜索结果页面和硕博论文详述页面的caj格式下载链接替换为pdf格式下载链接

目前為 2019-08-31 提交的版本,檢視 最新版本

// ==UserScript==
// @name         知网下载助手
// @namespace    [email protected]
// @version      1.3.1
// @description  解析CNKI论文PDF格式下载地址,论文搜索结果页面和硕博论文详述页面的caj格式下载链接替换为pdf格式下载链接
// @author       wyn665817
// @match        *://*.cnki.net/*
// @include      */brief.aspx*
// @include      */detail.aspx*
// @run-at       document-end
// @grant        unsafeWindow
// @supportURL   https://greasyfork.org/zh-CN/scripts/371938/feedback
// @license      MIT
// ==/UserScript==

var $ = unsafeWindow.jQuery,
url = location.pathname;

if (!$) {
} else if (url.match(/brief\.aspx$/)) {
    $('.GridTableContent tr[bgcolor]').each(function() {
        var $dl = $('.briefDl_Y, .briefDl_D', this),
        href = ($dl[0] || {}).href || '#';
        $dl.attr('href', href.replace(/&dflag=\w*|$/, '&dflag=pdfdown'));
    });
} else if (url.match(/detail\.aspx$/) && location.search.match(/dbcode=C[DM]FD&/i)) {
    $('.dllink > .icon').each(function() {
        var tip = $(this).text().trim();
        if (tip == '整本下载') {
            this.href = this.href.replace(/&dflag=\w*|$/, '&dflag=pdfdown');
        } else if (tip.match(/^分[页章]下载$/)) {
            this.href = this.href.replace('kns', 'gb.oversea').replace('kns', 'kcms') + '&cflag=pdf';
        }
    });
}