// ==UserScript== // @name 知网下载助手 // @namespace wyn665817@163.com // @version 1.4.0 // @description 解析CNKI论文PDF格式下载地址,论文搜索结果页面和硕博论文详述页面的caj格式下载链接替换为pdf格式下载链接 // @author wyn665817 // @match *://*.cnki.net/* // @include */brief.aspx* // @include */detail.aspx* // @connect cnki.net // @run-at document-end // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @supportURL https://greasyfork.org/zh-CN/scripts/371938/feedback // @license MIT // @downloadURL none // ==/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(/^https/, 'http').replace('kns', 'gb.oversea').replace('kns', 'kcms') + '&cflag=pdf'; } }); GM_xmlhttpRequest({ method: 'GET', url: $('a:contains(分章下载)').attr('href'), onload: function(xhr) { var list = $('tr', xhr.responseText).map(function() { var $dom = $(this).find('a, td:last'); return $dom.eq(0).html().trim().replace(/ /g, ' ') + '\t' + $dom.eq(1).text().trim().split('-')[0]; }).get().join('\n'); $('复制目录').click(function() { GM_setClipboard(list); alert('目录已复制到剪贴板'); }).prependTo('.dllink').toggle(!!list); } }); }