Redirect to UNSW Library

Redirect IEEE link to UNSW library

当前为 2024-04-19 提交的版本,查看 最新版本

// ==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://greasyforks.org/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();
    }
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。