Skip to content

Instantly share code, notes, and snippets.

@eranroz
Created August 15, 2014 17:02
Show Gist options
  • Save eranroz/d2e1f06440427b7cedfa to your computer and use it in GitHub Desktop.
Save eranroz/d2e1f06440427b7cedfa to your computer and use it in GitHub Desktop.
HUJI WebVPN link from scientific sites (greasemonkey script)
// ==UserScript==
// @name HUJI WebVPN
// @namespace eran
// @include https://samba.huji.ac.il/+CSCO+*/samba/web.html
// @include http://www.nature.com/.*
// @include http://bioinformatics.oxfordjournals.org/*
// @include http://www.cell.com/abstract/*
// @include http://www.cell.com/content/article/sdfulltext*
// @include http://online.liebertpub.com/doi/full/*
// @include http://www.pnas.org/content/*
// @include http://onlinelibrary.wiley.com/doi/*
// @version 1
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
function callWebVPN(){
GM_setValue('destUrl',document.location.href);
document.location.href='https://samba.huji.ac.il/+CSCOE+/logon.html';
}
//in samba
if(/samba\.huji\.ac\.il\/\+CSCO.*\/samba\/web\.html/.test(window.location.href)){
var s=GM_getValue("destUrl","");
if(s.length>0){
setTimeout(function(){
var mang = unsafeWindow.CSCO_WebVPN["mangle_url"](s,0);
document.location.href = mang;
},400)
}
}
else {
//in scietific site: create button to access using VPN
var hujiAccess = document.createElement('div');
hujiAccess.innerHTML = '<button id="hujiaccess" type="button" style="z-index:1000;right:0px;position:absolute;top:0px;">HUJI</button>';
document.body.appendChild (hujiAccess);
document.getElementById ("hujiaccess").addEventListener ("click", callWebVPN, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment