Jump to content

How to redirect a request to a random URL?


nasekt

Recommended Posts

I use [Fiddler](Understanding FiddlerScript ), Man in the middle proxy tool

var regex = /TargetString/gi ;if (regex.match(URL) {var request_arr = new Array( "www.bing.com", "www.google.com", "www.yahoo.com", "www.sandbox.com");var random_url = request_arr[Math.floor(Math.random() * request_arr.length)];

Basically, The above code says, if the TargetString is found in URL, then redirect it to a random URL.What I need, For example:If TargetString is found in www.example.com/TargetString redirect to by picking a random URL from array list and NOT to use THAT URL in the futureThank you

Link to comment
Share on other sites

If the web page is redirected, how would splicing the array work? the page is no longer loaded cause you've just been redirected.

 

now if that array was stored in a WebStorage object....

 

Which then you simply remove the url fro the arry as JSG says and then resave the array back into the session storage.

Link to comment
Share on other sites

//check this outvar target = "TargetString";var condition = (window.location.href.toLowerCase().indexOf(target.toLowerCase()) > -1 )?"random": "no-random" ;if (condition === "random") {var request_arr = ["www.bing.com", "www.google.com","www.yahoo.com","www.sandbox.com"];var random_url = request_arr[Math.floor(Math.random() * request_arr.length)];var cook = "url="+random_url+";expires=December 25, 2060;path=/";document.cookie = cook;var url = document.cookie.split(";");for(i=0;i<url.length;i++){if(url == random_url){random_url = request_arr[Math.ceil(Math.random() * request_arr.length )];break;} else{window.location = random_url;}}} else{//target string not found in url.}

Edited by kodejuice
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...