-
-
Save Jamonek/1ae01e2aa5359ea08110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this goes into every page where the hijack will take place | |
// or where the hijack will land | |
function hijack (abs, landing) { | |
// get the #jump=url from the url | |
url_hash = window.location.hash.substr(1); | |
// make sure its actually a #jump= | |
if (url_hash.indexOf("jump=") !== -1) { | |
// trim off jump= and redirect | |
url = window.location.hash.substr(6); | |
window.setTimeout(function(){ | |
window.location = url; | |
}, 2000); | |
} | |
// capture all a href elements and replace with landing | |
var element = document.getElementsByTagName('a'); | |
for (var i = 0; i < element.length; i++) { | |
// check if the url is absolute or not | |
if (element[i]['href'].indexOf('http') !== -1) { | |
element[i]['href'] = landing + element[i]['href']; | |
} | |
else { | |
element[i]['href'] = abs + landing + element[i]['href']; | |
} | |
} | |
} | |
hijack('http://ncat.edu/', 'ad.html#jump='); |
Decided to make this public.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Completely forgot about this.