// ==UserScript== // @name 知网下载助手 // @namespace wyn665817@163.com // @version 1.3.0 // @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 // @downloadURL none // ==/UserScript== var $ = unsafeWindow.jQuery, url = location.pathname; String.prototype.dbcode = function() { return this.match(/dbcode=C[DM]FD&/i); }; String.prototype.dflag = function() { return this.replace(/&dflag=\w*|$/, '&dflag=pdfdown'); }; String.prototype.kcms = function() { return this.replace('kns', 'gb.oversea').replace('kns', 'kcms'); }; if (!$) { } else if (url.match(/brief\.aspx$/)) { $('.GridTableContent tr[bgcolor]').each(function() { var $dl = $('.briefDl_Y, .briefDl_D', this), href = ($dl[0] || {}).href || '#'; href = $('.fz14', this).attr('href').dbcode() ? href.kcms() : href; $dl.attr('href', href.dflag()); }); } else if (url.match(/detail\.aspx$/) && location.search.dbcode()) { $('.dllink > .icon').each(function() { var tip = $(this).text().trim(); if (tip == '整本下载') { this.href = this.href.kcms().dflag(); } else if (tip.match(/^分[页章]下载$/)) { this.href = this.href.kcms() + '&cflag=pdf'; } }); }