Redirect to UNSW Library

Redirect IEEE link to UNSW library

Ekde 2024/04/19. Vidu La ĝisdata versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name Redirect to UNSW Library
// @version 1.0
// @description Redirect IEEE link to UNSW library
// @author  Caikun-Peng
// @license MIT
// @match https://ieeexplore.ieee.org/*
// @exclude https://ieeexplore-ieee-org.wwwproxy1.library.unsw.edu.au/*
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @grant GM_setClipboard
// @grant GM_registerMenuCommand
// @run-at document-end
// @namespace https://greatest.deepsurf.us/users/1290404
// ==/UserScript==

(function(){
    let ip
    let URL

    GM_registerMenuCommand("Manual Redirection", redirectManually)
    function redirectManually(){
        document.addEventListener(('click', changeURL))
    }

    GM_registerMenuCommand("Go to the UNSW Library", goToLibrary)
    function goToLibrary(){
        document.addEventListener(('click', window.open("https://www.library.unsw.edu.au/")))
    }

    function getIP(){
        GM_xmlhttpRequest({
            method: "GET",
            url: "http://api.ipify.org",
            onload: function(response) {
                ip = response.response
                if (ip.includes("129.94")) {
                } else{
                    changeURL();
                }
            }
        })
    }

    function changeURL(){
        URL = window.location.href.replace(/https\:\/\/ieeexplore.ieee.org/, 'https://ieeexplore-ieee-org.wwwproxy1.library.unsw.edu.au');
        window.open(URL,'_self');
    }

    var origin = window.location.origin;
    if (origin == "https://ieeexplore.ieee.org"){
        getIP();
    }
})();