Skip to content

Instantly share code, notes, and snippets.

@validkeys
Created August 5, 2014 11:54
Show Gist options
  • Select an option

  • Save validkeys/9de7b135de238a37c7e1 to your computer and use it in GitHub Desktop.

Select an option

Save validkeys/9de7b135de238a37c7e1 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="http://static.ziffdavis.com/js/zdgurgle/zdgurgler.min.js"> </script>
<script type="text/javascript">
function build_script( url ){
return '<script type="text/javascript" src="' + url + '"></' + 'script>';
}
window.addEventListener('message', function(e) {
// -----------------------
// Expects the data to be
// {
// url: 'http://some-url'
// }
// -----------------------
if ((e.data.url != null) && e.data.url.length > 0) {
var CS_segments = '', extraAdValues = '';
// -----------------------
// Cookie Script
// -----------------------
function CS_data_callback(cs_data) {
if (cs_data && cs_data.segments)
CS_segments = 'csseg=' + cs_data.segments.join(';csseg=');
}
(function(){
if(typeof document.referer !== 'undefined' && document.referer != ''){
if(document.location.search !=''){
var params = [ ], str;
var keys = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i=0;i < keys.length; i++){
str = keys[i].split('=');
params.push( str[0] );
params[str[0]] = str[1];
}
extraAdValues = "ref=" + params["ref"];
} else {
var hosturi = parseUri(document.referrer).host;
var uriArray = hosturi.split('.');
extraAdValues = 'ref=' + encodeURIComponent(uriArray.slice(uriArray.length-2).join('.'));
}
}
else{
extraAdValues = 'ref=null';
}
})();
extraAdValues += ZDGURGLER.GetAdString();
// -----------------------
// Write the passed script
// -----------------------
document.write( build_script(e.data.url) );
} else {
console.warn("No url found!");
}
}, false);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment