Greasy Fork 支持简体中文。

知网下载助手

论文搜索结果页面和硕博论文详述页面的caj格式下载链接替换为pdf格式下载链接

目前為 2018-09-05 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 知网下载助手
  3. // @namespace wyn665817@163.com
  4. // @version 1.0.0
  5. // @description 论文搜索结果页面和硕博论文详述页面的caj格式下载链接替换为pdf格式下载链接
  6. // @author wyn665817
  7. // @match *://*.cnki.net/*
  8. // @include *://*.cnki.net.*
  9. // @include *://*/cnki.net/*
  10. // @run-at document-end
  11. // @grant unsafeWindow
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. var $ = unsafeWindow.$,
  16. url = location.pathname,
  17. dbcode = ['CDFD', 'CMFD'];
  18.  
  19. if (url.endsWith('brief.aspx')) {
  20. var arr = new Array();
  21. $('.fz14').each(function() {
  22. arr.push(getQueryString('dbcode', this.href));
  23. });
  24. $('.briefDl_D, .briefDl_Y').each(function(index) {
  25. this.href = this.href.includes('&dflag') ? this.href.replace('&dflag=nhdown', '&dflag=pdfdown') : (this.href + '&dflag=pdfdown');
  26. if (dbcode.includes(arr[index])) {
  27. this.href = this.href.replace('kns', 'gb.oversea').replace('kns', 'kcms');
  28. }
  29. });
  30. } else if (url.endsWith('detail.aspx') && dbcode.includes(getQueryString('dbcode', location.search))) {
  31. $('.dllink > .icon').each(function() {
  32. url = $(this).text().trim();
  33. if (url == '整本下载') {
  34. this.href = this.href.replace('&dflag=nhdown', '&dflag=pdfdown');
  35. } else if (url == '分页下载' || url == '分章下载') {
  36. this.href += '&cflag=pdf';
  37. } else {
  38. return true;
  39. }
  40. this.href = this.href.replace('kns', 'gb.oversea').replace('kns', 'kcms');
  41. });
  42. }
  43.  
  44. function getQueryString(name, url) {
  45. var reg = new RegExp('(^|&|\\?)' + name + '=([^&]*)(&|$)', 'i'),
  46. r = url.match(reg);
  47. if (r != null) return decodeURI(r[2]); return null;
  48. }