Skip to content

Instantly share code, notes, and snippets.

@zhuth
Last active March 8, 2021 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuth/c8b6cf110b2311ced006bbd20682ad33 to your computer and use it in GitHub Desktop.
Save zhuth/c8b6cf110b2311ced006bbd20682ad33 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @id CNKI-PDF
// @name CNKI 中国知网 PDF 全文下载
// @version 1.2.2
// @namespace http://yuelong.info
// @author YUE Long, zhuth
// @description 点击 CNKI 检索结果界面中的下载按钮可以直接下载 PDF 格式文献
// @include https://kns.cnki.net/*
// @include http://kns.cnki.net/*
// @run-at document-idle
// ==/UserScript==
(function() {
var allLinks = document.querySelectorAll('a.downloadlink,a[href*="download.aspx"]');
function fix_link(li) {
var h = li.href;
if (h.indexOf('&dflag=') > 0) {
li.href = h.replace('&dflag=nhdown', '&dflag=pdfdown');
} else {
li.href = h + '&dflag=pdfdown';
}
}
for (var li of allLinks) fix_link(li);
jQuery(document).on('mouseover', 'a.downloadlink', function () {
fix_link(this);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment