Redirect IEEE link to UNSW library
Ekde
// ==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();
}
})();