Skip to content

Instantly share code, notes, and snippets.

@tomac4t
Last active January 17, 2023 01:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomac4t/58b562fb44f67011b3d0dd0a6808f185 to your computer and use it in GitHub Desktop.
Save tomac4t/58b562fb44f67011b3d0dd0a6808f185 to your computer and use it in GitHub Desktop.
Provide PDF download button for master's thesis on cnki.net
// ==UserScript==
// @name cnki-pdf-download.user.js
// @namespace https://tomcat.one/
// @version 1.4
// @description Provide PDF Download button for master's thesis on cnki.net
// @author tomacat
// @match http://kns.cnki.net/KCMS/detail/detail.aspx?*
// @match https://kns.cnki.net/KCMS/detail/detail.aspx?*
// @grant none
// @license The Unlicense
// @require https://piccache.cnki.net/kdn/kns/script/jQuery-1.11.3.min.js
// @run-at document-end
// ==/UserScript==
(function() {
if ($('#pdfDown').length == 0){
console.log("The PDF button is not existing.");
cdjDownload = $('.icon-dlGreen')[0].href;
// Replace the link.
pdfDownload = cdjDownload.replace("dflag=nhdown", "dflag=pdfdown");
overseaDownload = pdfDownload.replace("https://kns.cnki.net/kns/download.aspx", "http://gb.oversea.cnki.net/kcms/download.aspx");
anchorLink = "<a href='" + overseaDownload + "' class='icon icon-dlpdf' rel='noreferrer' target='_blank'>PDF下载</a>";
$(".dllink").append(anchorLink);
if($('.icon-dlpdf').length >= 1){
console.log("A PDF button has been added.");
}
$(".rootw .wxToolbar .dllink").css("margin-right", "200px");
$(".rootw .wxToolbar .infotxt").css("width", "160px");
} else {
console.log("The PDF button is existing.");
}
// Unbind onclick event.
$('.icon-dlGreen,.icon-dlBlue').prop("onclick", null).off("click");
}).apply(null);
@tomac4t
Copy link
Author

tomac4t commented May 7, 2022

This userscript won't work anymore due to gb.oversea.cnki.net was shutdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment