Last active
January 17, 2023 01:18
-
-
Save tomac4t/58b562fb44f67011b3d0dd0a6808f185 to your computer and use it in GitHub Desktop.
Provide PDF download button for master's thesis on cnki.net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This userscript won't work anymore due to gb.oversea.cnki.net was shutdown.