sciencedirect+ieeexplore+tandfonline+springer跳转CUMT_按钮

sciencedirect+ieeexplore+tandfonline跳转 CUMT

  1. // ==UserScript==
  2. // @name sciencedirect+ieeexplore+tandfonline+springer跳转CUMT_按钮
  3. // @license Apache
  4. // @namespace hanzhang
  5. // @version 1.0.1
  6. // @description sciencedirect+ieeexplore+tandfonline跳转 CUMT
  7. // @author hanzhang
  8. // @match https://www.sciencedirect.com/science/*
  9. // @match https://ieeexplore.ieee.org/*
  10. // @match https://www.tandfonline.com/doi/*
  11. // @match https://link.springer.com/article/*
  12. // @match https://www.springer.com/*
  13. // @match https://pubsonline.informs.org/doi/*
  14. // @icon https://www.google.com/s2/favicons?sz=64&domain=sciencedirect.com
  15. // @grant GM_openInTab
  16.  
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. 'use strict';
  21. var html_title=new Array()
  22. html_title[0]= "www.sciencedirect.com"
  23. html_title[1]= "ieeexplore.ieee.org"
  24. html_title[2]= "www.tandfonline.com"
  25. html_title[3]= "www.springer.com"
  26. html_title[4]= "link.springer.com"
  27. html_title[5]="pubsonline.informs.org"
  28. //html_title[6]="onlinelibrary.wiley.com"
  29. //let link = location.href;
  30. function addButton() {
  31. let link = window.location.host
  32. if(link==html_title[0])
  33. {
  34. // 找到目标元素
  35. let targetElement = document.querySelector("#popover-trigger-export-citation-popover");
  36.  
  37. if (targetElement && !document.getElementById("other-button")) {
  38. // 创建新的按钮元素
  39. let newButton = document.createElement("button");
  40. newButton.id = "other-button"; // 给按钮添加一个ID,避免重复添加
  41. newButton.className = "button-link button-link-secondary button-link-icon-left button-link-has-colored-icon";
  42. newButton.type = "button";
  43. newButton.innerHTML = `
  44. <svg focusable="false" viewBox="0 0 104 128" height="20" class="icon icon-cited-by-66">
  45. <path d="M50 10L90 50L50 90L10 50Z"></path>
  46. </svg>
  47. <span class="button-link-text-container">
  48. <span class="button-link-text">跳转CUMT</span>
  49. </span>
  50. `;
  51. // 设置按钮的颜色样式
  52. newButton.style.backgroundColor = "#007BFF"; // 设置背景颜色为蓝色
  53. newButton.style.color = "white"; // 设置文字颜色为白色
  54. newButton.style.border = "none"; // 移除按钮边框
  55. newButton.style.padding = "6px 8px"; // 设置按钮的内边距
  56. newButton.style.borderRadius = "5px"; // 设置圆角
  57. // 为新按钮添加点击事件
  58. newButton.addEventListener("click", function() {
  59. //alert("新按钮被点击了!");
  60. // 在此处添加你想执行的代码
  61. //debugger;
  62. link = location.href;
  63. link = link.replace('www.sciencedirect.com','www-sciencedirect-com-s.webvpn.cumt.edu.cn:8118');
  64. GM_openInTab(link, { active: true });
  65. });
  66.  
  67. // 将新按钮添加到目标元素中
  68. targetElement.appendChild(newButton);
  69. }
  70. }
  71. else if(link==html_title[1])
  72. {
  73. // 找到目标元素
  74. let targetElement = document.querySelector(".xpl-btn-secondary");
  75.  
  76. if (targetElement && !document.getElementById("other-button")) {
  77. // 创建新的按钮元素
  78. let newButton = document.createElement("button");
  79. newButton.id = "other-button"; // 给按钮添加一个ID,避免重复添加
  80. newButton.className = "layout-btn-white cite-this-btn"; // 复制原按钮的样式,或使用新的样式
  81. newButton.type = "button";
  82. newButton.innerHTML = "跳转CUMT"; // 按钮的文本内容
  83. // 设置按钮的颜色样式
  84. newButton.style.backgroundColor = "#007BFF"; // 设置背景颜色为蓝色
  85. newButton.style.color = "white"; // 设置文字颜色为白色
  86. newButton.style.border = "none"; // 移除按钮边框
  87. newButton.style.padding = "10px 15px"; // 设置按钮的内边距
  88. newButton.style.borderRadius = "5px"; // 设置圆角
  89. // 为新按钮添加点击事件
  90. newButton.addEventListener("click", function() {
  91. link = location.href;
  92. var regex1 = 'https://ieeexplore.ieee.org/abstract/';
  93. var flag1 =link.search(regex1);
  94. if(flag1!=-1)
  95. {
  96. link = link.replace('ieeexplore.ieee.org/abstract/','ieeexplore-ieee-org-s.webvpn.cumt.edu.cn:8118/');
  97. }
  98. var regex2 = 'https://ieeexplore.ieee.org/';
  99. var flag2 =link.search(regex2);
  100. if(flag2!=-1)
  101. {
  102. link = link.replace('ieeexplore.ieee.org/','ieeexplore-ieee-org-s.webvpn.cumt.edu.cn:8118/');
  103. }
  104.  
  105. GM_openInTab(link, { active: true });
  106.  
  107.  
  108.  
  109.  
  110. });
  111.  
  112. // 将新按钮插入到目标元素的旁边
  113. targetElement.parentNode.insertBefore(newButton, targetElement.nextSibling);
  114. //newButton.parentNode.appendChild(newButton);
  115. // 将新按钮插入到DOI元素之后
  116. }
  117. }
  118. else if(link==html_title[2])
  119. {
  120. // 找到目标元素
  121. let doiElement = document.querySelector(".dx-doi");
  122.  
  123. if (doiElement && !document.getElementById("other-button")) {
  124. // 创建新的按钮元素
  125. let newButton = document.createElement("button");
  126. newButton.id = "other-button"; // 给按钮添加一个ID,避免重复添加
  127. newButton.className = "button-link button-link-secondary button-link-icon-left button-link-has-colored-icon";
  128. newButton.type = "button";
  129. newButton.innerHTML = `
  130. <span class="button-link-text-container">
  131. <span class="button-link-text">跳转CUMT</span>
  132. </span>
  133. `;
  134. // 设置按钮的颜色样式
  135. newButton.style.backgroundColor = "#007BFF"; // 设置背景颜色为蓝色
  136. newButton.style.color = "white"; // 设置文字颜色为白色
  137. newButton.style.border = "none"; // 移除按钮边框
  138. newButton.style.padding = "10px 15px"; // 设置按钮的内边距
  139. newButton.style.borderRadius = "5px"; // 设置圆角
  140. // 为新按钮添加点击事件
  141. newButton.addEventListener("click", function() {
  142. link = location.href;
  143. link = link.replace('www.tandfonline.com','www-tandfonline-com-s.webvpn.cumt.edu.cn:8118');
  144.  
  145. GM_openInTab(link, { active: true });
  146. });
  147. doiElement.insertAdjacentElement('afterend', newButton);
  148. }
  149. }
  150. else if(link==html_title[4])
  151. {
  152. // 找到目标元素
  153. let targetElement = document.querySelector(".c-article-identifiers__item time");
  154.  
  155. if (targetElement && !document.getElementById("other-button")) {
  156. // 创建新的按钮元素
  157. let newButton = document.createElement("button");
  158. newButton.id = "other-button"; // 给按钮添加一个ID,避免重复添加
  159. newButton.className = "button-link button-link-secondary";
  160. newButton.type = "button";
  161. newButton.innerText = "跳转CUMT";
  162. // 设置按钮的颜色样式
  163. newButton.style.backgroundColor = "#007BFF"; // 设置背景颜色为蓝色
  164. newButton.style.color = "white"; // 设置文字颜色为白色
  165. newButton.style.border = "none"; // 移除按钮边框
  166. newButton.style.padding = "10px 15px"; // 设置按钮的内边距
  167. newButton.style.borderRadius = "5px"; // 设置圆角
  168. // 为新按钮添加点击事件
  169. newButton.addEventListener("click", function() {
  170. link = location.href;
  171. link = link.replace('link.springer.com','link-springer-com-s.webvpn.cumt.edu.cn:8118');
  172. GM_openInTab(link, { active: true });
  173. });
  174.  
  175. // 将新按钮插入到目标元素后面
  176. targetElement.parentNode.insertBefore(newButton, targetElement.nextSibling);
  177. }
  178. }
  179. else if(link==html_title[5])
  180. {
  181. // 找到目标元素
  182. let targetElement = document.querySelector(".epub-section__item");
  183.  
  184. if (targetElement && !document.getElementById("other-button")) {
  185. // 创建新的按钮元素
  186. let newButton = document.createElement("button");
  187. newButton.id = "other-button"; // 给按钮添加一个ID,避免重复添加
  188. newButton.className = "button-link";
  189. newButton.type = "button";
  190. newButton.style.marginLeft = "10px"; // 设置按钮与前面元素的间距
  191. newButton.textContent = "跳转CUMT";
  192. // 设置按钮的颜色样式
  193. newButton.style.backgroundColor = "#007BFF"; // 设置背景颜色为蓝色
  194. newButton.style.color = "white"; // 设置文字颜色为白色
  195. newButton.style.border = "none"; // 移除按钮边框
  196. newButton.style.padding = "10px 15px"; // 设置按钮的内边距
  197. newButton.style.borderRadius = "5px"; // 设置圆角
  198. // 为新按钮添加点击事件
  199. newButton.addEventListener("click", function() {
  200. link = location.href;
  201. link = link.replace('pubsonline.informs.org','pubsonline-informs-org-s.webvpn.cumt.edu.cn:8118');
  202. GM_openInTab(link, { active: true });
  203. });
  204.  
  205. // 将新按钮插入到目标元素的后面
  206. targetElement.insertAdjacentElement('afterend', newButton);
  207. }
  208. }
  209. }
  210.  
  211.  
  212.  
  213.  
  214.  
  215. // 首次调用以添加按钮
  216. addButton();
  217. // 使用setTimeout延迟添加按钮
  218. setTimeout(addButton, 500); // 0.5秒后尝试添加按钮
  219. // 监控DOM变化,确保按钮不会被移除
  220. var observer = new MutationObserver(function(mutations) {
  221. mutations.forEach(function(mutation) {
  222. addButton(); // 在DOM发生变化时重新尝试添加按钮
  223. });
  224. });
  225.  
  226. // 开始监控目标节点的子树变化
  227. observer.observe(document.body, { childList: true, subtree: true });
  228.  
  229. })();

QingJ © 2025

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