UTS Library Redirect

自动从ACM、IEEE、Springer和ScienceDirect重定向到悉尼科技大学图书馆。

  1. // ==UserScript==
  2. // @name UTS Library Redirect
  3. // @name:zh-CN UTS Library Redirect
  4. // @namespace https://github.com/yujianke100/University-Library-Redirect/tree/UTS
  5. // @version 1.1.5
  6. // @description Automatically redirect from ACM, IEEE, Springer and ScienceDirect to UTS Library.
  7. // @description:zh-CN 自动从ACM、IEEE、Springer和ScienceDirect重定向到悉尼科技大学图书馆。
  8. // @author Jianke Yu
  9. // @match https://dl.acm.org/*
  10. // @match https://ieeexplore.ieee.org/*
  11. // @match https://link.springer.com/*
  12. // @match https://www.sciencedirect.com/*
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18. var currentURL = window.location.href;
  19. var newURL;
  20. var proxySuffix = ".ezproxy.lib.uts.edu.au";
  21. // Function to check if the URL has already been redirected
  22. function isRedirected(url) {
  23. return url.includes(proxySuffix) || url.includes("redirected=true") || url.includes("%3Fredirected%3Dtrue") || url.includes("arnumber=");
  24. }
  25.  
  26. if (!isRedirected(currentURL)) {
  27. if (currentURL.startsWith("https://dl.acm.org/")) {
  28. newURL = currentURL.replace("https://dl.acm.org/", "https://dl-acm-org" + proxySuffix + "/") + "?redirected=true";
  29. } else if (currentURL.startsWith("https://ieeexplore.ieee.org/")) {
  30. newURL = currentURL.replace("https://ieeexplore.ieee.org/", "https://ieeexplore-ieee-org" + proxySuffix + "/") + "?redirected=true";
  31. } else if (currentURL.startsWith("https://link.springer.com/")) {
  32. newURL = currentURL.replace("https://link.springer.com/", "https://link-springer-com" + proxySuffix + "/") + "?redirected=true";
  33. } else if (currentURL.startsWith("https://www.sciencedirect.com/")) {
  34. newURL = currentURL.replace("https://www.sciencedirect.com/", "https://www-sciencedirect-com" + proxySuffix + "/") + "?redirected=true";
  35. }
  36.  
  37. if (newURL) {
  38. window.location.href = newURL;
  39. }
  40. }
  41. })();