Last active
March 26, 2022 02:59
-
-
Save Xzonn/66380e1bc34d08bc5201d53278eac83f to your computer and use it in GitHub Desktop.
中国知网(CNKI)硕博论文跳转至“海外版”下载 pdf 文件
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 文件 | |
// @namespace https://xzonn.top/ | |
// @version 1.0.2 | |
// @description 将中国知网(CNKI)搜索列表中的硕博论文详情页自动跳转至“海外版”网站,以便下载 pdf 文件。 | |
// @author Xzonn | |
// @include http*://kns.cnki.net/kns8/defaultresult/index | |
// @icon https://www.cnki.net/favicon.ico | |
// @grant none | |
// @supportURL https://xzonn.top/posts/Download-Pdf-File-from-Cnki.html | |
// @license cc by-nc-sa 4.0 | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let changeLink = function (e) { | |
let target = e.target; | |
while (target.tagName.toLowerCase() != "a") { | |
if (target.tagName.toLowerCase() == "body") { | |
return; | |
} | |
target = target.parentNode; | |
} | |
if (target.href && target.href.match(/^https?:\/\/kns\.cnki\.net\/(.*=(?:CMFD|CDFD)(?:&.*)?)$/)) { | |
target.href = target.href.replace(/^https?:\/\/kns\.cnki\.net\/(.*=(?:CMFD|CDFD)(?:&.*)?)$/, "https://chn.oversea.cnki.net/$1"); | |
} | |
}; | |
document.body.addEventListener("mousedown", changeLink); | |
document.body.addEventListener("click", changeLink); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment