Created
October 13, 2014 20:25
-
-
Save freejoe76/e6e2d3cf37288a00498a to your computer and use it in GitHub Desktop.
iframe_breaker.js
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
if (top !== self) | |
{ | |
// We want to track when this happens, which we do with a custom | |
// ?source=framebuster query added to the URL. | |
// The challenge is, often there's already a ?source=rss on the URL, | |
// which means we have to handle that too. | |
var sourcedomain = 'denverpost.com'; | |
var sourceurl = self.document.location.toString(); | |
var referrer = document.referrer.split('/')[2]; | |
if ( sourceurl.indexOf("www." + sourcedomain) > 0 && referrer.indexOf(sourcedomain) < 0 ) | |
{ | |
if ( referrer.indexOf("google") < 0 && referrer.indexOf("facebook") < 0 && referrer.indexOf("images.") < 0 && referrer.indexOf("ow.ly") < 0 && referrer.indexOf("reddit") < 0 && referrer.indexOf("stumbleupon") < 0 ) | |
{ | |
top.location.replace(self.location); | |
var sourcetag = "skipframe-" + referrer; | |
if ( sourceurl.indexOf("?source") > 0 || sourceurl.indexOf("&source") > 0 ) | |
{ | |
top.location.replace(sourceurl + sourcetag); | |
} | |
else if ( sourceurl.indexOf("?") == -1 ) | |
{ | |
top.location.replace(sourceurl + "?source=" + sourcetag); | |
} | |
else | |
{ | |
top.location.replace(sourceurl + sourcetag); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment