Yohannon (yohannon) wrote,
Yohannon
yohannon

  • Mood:

Not Leaving Well Enough...

Alrighty... here's the version that let's you ban a set of sites:

<script language="JavaScript">
<!--Hide JavaScript
var theBanned = new isnArray("dimensionsmagazine", "meineziele");
var theRedirect = "http://www.rotunda.com/people/yohannon/no_feeders.html"
// Build an array initializer
function isnArray() {
	argnr=isnArray.arguments.length
	for (var i=0;i<argnr;i++) {
	this[i+1] = isnArray.arguments[i];
	}
}
	var theRef=document.referrer;
	for (var x=0;x<argnr;x++) {
			if (theRef.indexOf(theBanned[x]) > 0)
				{
	location.replace(theRedirect)
				}
		}
	// End hiding of script -->
</script>


Update: Okay, I've gotten a couple of off-line comments complaining about the LACK of comments in this code. It's really simple, I swear.

The nice thing aboutn this code is that you only have to tweak two lines. The first line is a list of keywords to search for to do the re-direct. To change or add sites, you just create a comma delimited list, thusly:

"foo","bar","sleazy.com"

The nice thing about that approach is that you can add as many sites/keywords as you want.

The second line is simply an URL you'd like to send this badboy to. The way I do it is cool, as the person redirected can NOT simply hit the back button in the browser to avoid dealing. In fact, the only way they can get to the site at all is if they snag the URL and paste it manually.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments