将##知网(CNKI)搜索列表中的硕博论文详情页自动跳转至“海外版”网站,以便下载 pdf 文件。
// ==UserScript== // @name ##知网(CNKI)硕博论文跳转至“海外版”下载 pdf 文件 // @namespace https://xzonn.top/ // @version 1.0.2 // @description 将##知网(CNKI)搜索列表中的硕博论文详情页自动跳转至“海外版”网站,以便下载 pdf 文件。 // @author Xzonn // @include http*://kns.cnki.net/kns8/defaultr###lt/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); })();