// ==UserScript== // @name 中国知网CNKI硕博论文PDF下载 // @version 0.6 // @description 添加知网CNKI硕博论文PDF下载按钮/add PDF download button to CNKI. // @author leftjie // @include http*://*/kcms/detail/detail.aspx?dbcode=CMFD* // @include http*://*/kcms/detail/detail.aspx?dbcode=CDFD* // @include http*://*/KCMS/detail/detail.aspx?dbcode=CMFD* // @include http*://*/KCMS/detail/detail.aspx?dbcode=CDFD* // @match http*://kns.cnki.net/kcms/detail/detail.aspx?dbcode=CMFD* // @match http*://kns.cnki.net/kcms/detail/detail.aspx?dbcode=CDFD* // @match http*://kns.cnki.net/KCMS/detail/detail.aspx?dbcode=CMFD* // @match http*://kns.cnki.net/KCMS/detail/detail.aspx?dbcode=CDFD* // @match http*://cdmd.cnki.com.cn/Article/CDMD-* // @include http*://*/kcms/detail/detail.aspx?*dbcode=CDFD* // @include http*://*/kcms/detail/detail.aspx?*dbcode=CJFD* // @include http*://*/kcms/detail/detail.aspx?*dbcode=CMFD* // @include http*://*/KCMS/detail/detail.aspx?*dbcode=CDFD* // @include http*://*/KCMS/detail/detail.aspx?*dbcode=CJFD* // @include http*://*/KCMS/detail/detail.aspx?*dbcode=CMFD* // @grant none // @namespace https://greasyfork.org/users/244539 // @downloadURL none // ==/UserScript== //知网硕博论文页面 (function() { 'use strict'; window.onload = function(){ var url = window.location.href; var dllink = document.getElementsByClassName('operate-btn'); var dl = ""; for (var i = 0;i <= dllink.length; i++) { var nhdown = dllink[i].getElementsByTagName('a'); if (i == 0){ dl = nhdown[1].href.replace('dflag=nhdown','dflag=pdfdown').replace('dflag=cajdown','dflag=pdfdown'); }else{ dl = nhdown[0].href.replace('dflag=nhdown','dflag=pdfdown').replace('dflag=cajdown','dflag=pdfdown'); } var li = document.createElement('li'); var a = document.createElement('a'); li.className = "btn-dlpdf"; a.innerHTML = "PDF 下载"; a.href = dl; a.style.backgroundColor="#fb4376"; li.appendChild(a); document.getElementsByClassName('operate-btn')[i].appendChild(li); } }; })(); //知网空间学位论文 (function() { var url = window.location.href; if(url.indexOf('cdmd.cnki.com.cn') != -1){ var cnki_space_id = url.match(/-([0-9]+).htm/)[1]; console.log(cnki_space_id); var ty_caj = document.getElementById("ty_caj"); var newe = document.createElement("div"); var newe_a = document.createElement('a'); newe.className = "down_button"; newe.id = "ty_pdf"; newe_a.innerHTML = "PDF 下载(跳)"; newe_a.href = "https://kns.cnki.net/kcms/detail/detail.aspx?dbcode=CMFD&dbname=CMFDTEMP&filename=" + cnki_space_id + ".nh"; newe_a.target = "_blank"; newe.appendChild(newe_a); document.getElementById("down_3").insertBefore(newe,ty_caj); } })();