知网-文献-bibtex提取

重庆邮电大学 从知网文献中直接复制bibtex

  1. // ==UserScript==
  2. // @name 知网-文献-bibtex提取
  3. // @namespace https://www.tampermonkey.net/
  4. // @require https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
  5. // @version 1.2.5
  6. // @description 重庆邮电大学 从知网文献中直接复制bibtex
  7. // @author BN_Dou
  8. // @license AGPL License
  9. // @match https://kns.cnki.net/kcms/detail/detail.aspx?dbcode=*
  10. // @match http://202.202.43.73:8000/rwt/CNKI*
  11. // @match http://202.202.43.73:8000/rwt/CNKI/https/NNYHGLUDN3WXTLUPMW4A/kcms/detail/detail.aspx?dbcode=*
  12. // @match 202.202.43.73:8000/rwt/CNKI/https/NNYHGLUDN3WXTLUPMW4A/kcms/detail/detail.aspx?dbcode=*
  13. // @match 202.202.43.73:8000/rwt/CNKI*
  14. // @grant none
  15. // @require http://code.jquery.com/jquery-3.x-git.min.js
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. jQuery(document).ready(function($) {
  22.  
  23. window.onload = function(){
  24.  
  25. var a = document.getElementById("paramdbname")
  26. var b = document.getElementById("paramfilename")
  27. var fileid = a.getAttribute("value") + '!' + b.getAttribute("value") +'!1!0'
  28.  
  29. //添加按钮
  30. var x = document.getElementsByClassName("btn-tool")
  31. var input = document.createElement('li')
  32. input.setAttribute("id", "bibbtn")
  33. input.setAttribute("class", "btn-note")
  34. input.setAttribute("title", "Bibtex")
  35. input.innerHTML = ">>Bibtex<<"
  36. input.style = "width: 72px;height: 23px;cursor: pointer;color: #e8e6e3;"
  37. x[0].children[0].append(input)
  38.  
  39. //按下按钮
  40. $("#bibbtn").click(function(){
  41. $.post("https://kns.cnki.net/kns8/manage/APIGetExport",
  42. {
  43. filename:fileid,
  44. displaymode:"NoteExpress"
  45. },
  46.  
  47. function(data){
  48. console.log(data);
  49. var bibtext = ""
  50. var ss = data.data[0].value[0]
  51. var ssl = ss.split("<br>")
  52. var label = ""
  53. for (var j=0; j<ssl.length-1; j++){
  54. var kk = ssl[j].toLocaleLowerCase().split(" ").join("").split("}:")
  55. if(kk[0] == "{author"){
  56. label = kk[1].split(";")[0]
  57. }
  58. }
  59. for (var i=0; i<ssl.length-1; i++){
  60. var k = ssl[i].toLocaleLowerCase().split(" ").join("").split("}:")
  61. var item = k[0]
  62. var detail = k[1]
  63. if (item == "{referencetype"){
  64. if (detail == "journalarticle"){
  65. bibtext = "@article{" + label + ",\n"
  66. }
  67. else if(detail == "conferenceproceedings"){
  68. bibtext = "@inproceedings{" + label + ",\n"
  69. }
  70. else if(detail == "patent"){
  71. bibtext = "@patent{" + label + ",\n"
  72. }
  73. else if(detail == "thesis"){
  74. bibtext = "@thesis{" + label + ",\n"
  75. }
  76. }
  77. else if(item == "{issue"){
  78. bibtext = bibtext + " number={" + detail + "},\n"
  79. }
  80. else if(item == "{title"){
  81. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail.toLocaleUpperCase() + "},\n"
  82. }
  83. else if(item == "{author"){
  84. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail.split(";").join(" and ").substr(0, detail.split(";").join(" and ").length-5) + "},\n"
  85. }
  86. else if(item == "{authoraddress"){
  87. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail.toLocaleUpperCase() + "},\n"
  88. }
  89. else if(item == "{journal"){
  90. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail.toLocaleUpperCase() + "},\n"
  91. }
  92. else if(item == "{keywords"){
  93. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail.toLocaleUpperCase() + "},\n"
  94. }
  95. else if(item == "{abstract"){
  96. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail.toLocaleUpperCase() + "},\n"
  97. }
  98. else{
  99. bibtext = bibtext + " " + item.substr(1, item.length-1) + "={" + detail + "},\n"
  100. }
  101. }
  102. bibtext += "}"
  103. //console.log(bibtext)
  104. const copad = document.createElement('textarea')
  105. copad.value = bibtext
  106. document.body.appendChild(copad)
  107. copad.select()
  108. document.execCommand('Copy')
  109. document.body.removeChild(copad)
  110. });
  111. })
  112. };
  113. })
  114. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址