Click2Redirect

Inserts a floating button in the page and you can click it to get ariticles.

  1. // ==UserScript==
  2. // @name Click2Redirect
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @author Encounter925
  6. // @description Inserts a floating button in the page and you can click it to get ariticles.
  7. // @license MIT
  8. // @match *://*.cnki.net/*
  9. // @match *://*.bj.cxstar.cn/*
  10. // @match *://*.blyun.com/*
  11. // @match *://*.zhizhen.com/*
  12. // @match *://qikan.chaoxing.com/*
  13. // @match *://*.innojoy.com/*
  14. // @match *://*.duxiu.com/*
  15. // @match *://*.epsnet.com.cn/*
  16. // @match *://*.keledge.com/*
  17. // @match *://*.qdexam.com/*
  18. // @match *://*.yjsexam.com/*
  19. // @match *://*.fenqubiao.com/*
  20. // @match *://*.engineeringvillage.com/*
  21. // @match *://*.emerald.com/*
  22. // @match *://*.nature.com/*
  23. // @match *://onepetro.org/*
  24. // @match *://*.onepetro.org/*
  25. // @match *://*.iresearchbook.cn/*
  26. // @match *://*.pqdtcn.com/*
  27. // @match *://*.sciencedirect.com/*
  28. // @match *://*.sciencemag.org/*
  29. // @match *://*.science.org/*
  30. // @match *://*.newacademic.net/*
  31. // @match *://*.wanfangdata.com.cn/*
  32. // @match *://*.wiley.com/*
  33. // @grant GM_addStyle
  34. // ==/UserScript==
  35.  
  36. (function() {
  37. 'use strict';
  38.  
  39. var currentUrl = window.location.href; //get current url
  40.  
  41. var urlObj = new URL(currentUrl);
  42.  
  43. // 获取服务器地址(包括协议和主机名)
  44. var serverAddress = urlObj.origin;
  45.  
  46. var modifiedAssress = serverAddress.replace(/\./g, '-');
  47. modifiedAssress = modifiedAssress+'-s.atrust.yangtzeu.edu.cn';
  48.  
  49. // 获取文件路径(不包括服务器地址)
  50. var filePath = currentUrl.substring(serverAddress.length);
  51.  
  52. var destiUrl = modifiedAssress+filePath;
  53.  
  54. // Create container for buttons
  55. var container = document.createElement('div');
  56. container.style.position = 'fixed';
  57. container.style.top = '15%';
  58. container.style.right = '12px';
  59. container.style.zIndex = '9999';
  60. container.style.display = 'flex';
  61. container.style.flexDirection = 'column';
  62. container.style.gap = '10px';
  63.  
  64. // Create first button
  65. var button1 = document.createElement('button');
  66. button1.innerHTML = '重定向';
  67. button1.style.padding = '10px';
  68. button1.style.cursor = 'pointer';
  69. button1.onclick = function() {
  70. // alert("Server:"+serverAddress+"\n"
  71. // +"ModifiedServer:"+modifiedAssress+"\n"
  72. // +"Path:"+filePath);
  73. alert("我们将跳转至:"+destiUrl);
  74. window.location.href = destiUrl;
  75. // window.open(destiUrl);
  76. };
  77. // Create second button
  78. var button2 = document.createElement('button');
  79. button2.innerHTML = '登陆';
  80. button2.style.padding = '10px';
  81. button2.style.cursor = 'pointer';
  82. button2.onclick = function() {
  83. // alert('Button 2 clicked!');
  84. window.open('https://atrust.yangtzeu.edu.cn:4443/');
  85. };
  86.  
  87. // Add buttons to container
  88. container.appendChild(button1);
  89. container.appendChild(button2);
  90.  
  91. // Add container to the body
  92. document.body.appendChild(container);
  93. })();