Greasy Fork is available in English.

Redirect to UNSW Library

Redirect ACM, IEEE, Springer and ScienceDirect to UNSW Library.

  1. // ==UserScript==
  2. // @name Redirect to UNSW Library
  3. // @namespace https://github.com/Caikun-Peng/Redirect-to-UNSW-Library/blob/main/redirection.js
  4. // @version 1.1
  5. // @description:en Redirect ACM, IEEE, Springer and ScienceDirect to UNSW Library.
  6. // @description:zh 将ACM、IEEE、Springer和ScienceDirect网站重定向至UNSW图书馆。
  7. // @author Caikun-Peng
  8. // @match https://dl.acm.org/*
  9. // @match https://ieeexplore.ieee.org/*
  10. // @match https://link.springer.com/*
  11. // @match https://www.sciencedirect.com/*
  12. // @grant GM_xmlhttpRequest
  13. // @license MIT
  14. // @description Redirect ACM, IEEE, Springer and ScienceDirect to UNSW Library.
  15. // ==/UserScript==
  16.  
  17. (function(){
  18. 'use strict';
  19.  
  20. var origin
  21. var newURL
  22. var flag
  23.  
  24. function main() {
  25. GM_xmlhttpRequest({ // Get IP address
  26. method: "GET",
  27. url: "https://api.ipify.org?format=json",
  28. onload: function(response) {
  29. var ip = JSON.parse(response.responseText).ip;
  30. if (ip.includes("129.94")) {
  31. flag = 0;
  32. } else{
  33. flag = 1;
  34. }
  35. if (flag) {
  36. newURL = changeURL();
  37. window.location.href = newURL;
  38. }
  39. }
  40. });
  41. }
  42.  
  43. function changeURL(){
  44. if (origin.startsWith("https://dl.acm.org/")) {
  45. return origin.replace("https://dl.acm.org/", "https://dl-acm-org.wwwproxy1.library.unsw.edu.au/");
  46. }
  47. else if (origin.startsWith("https://ieeexplore.ieee.org/")) {
  48. return origin.replace("https://ieeexplore.ieee.org/", "https://ieeexplore-ieee-org.wwwproxy1.library.unsw.edu.au/");
  49. }
  50. else if (origin.startsWith("https://link.springer.com/")) {
  51. return origin.replace("https://link.springer.com/", "https://link-springer-com.wwwproxy1.library.unsw.edu.au/");
  52. }
  53. else if (origin.startsWith("https://www.sciencedirect.com/")) {
  54. return origin.replace("https://www.sciencedirect.com/", "https://www-sciencedirect-com.wwwproxy1.library.unsw.edu.au/");
  55. }
  56. }
  57.  
  58. origin = window.location.href;
  59. main();
  60.  
  61. })();