-
Notifications
You must be signed in to change notification settings - Fork 4
/
affililink.min.js
6 lines (6 loc) · 3.12 KB
/
affililink.min.js
1
2
3
4
5
6
/*
* Affililink v0.21
* http://affililink.com
* Created by Dean Barrow (http://deanbarrow.co.uk)
*/
var affililink,curronload,newonload;affililink=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;e={campaign:0,country:""};i={"amazon.co.uk":"tag=","amazon.com":"tag=","amazon.de":"tag=","amazon.fr":"tag=","javari.co.uk":"tag=","javari.de":"tag=","javari.fr":"tag=","amazonsupply.com":"tag=","amazonwireless.com":"tag=","endless.com":"tag="};g={replace_links:true,track_views:false,track_clicks:true};h=function(){if(window.gat_&&window.gat_.getTracker_){if(g["track_clicks"]){j.setAttribute("onclick","_gaq.push(['_trackEvent', 'Affililink', 'Click', "+j.href+"]);")}if(g["track_views"]){_gaq.push(["_trackEvent","Affililink","View",j.href])}}return true};d=function(){var a,b,d,f;if(e["campaign"]&&e["country"]){b=["ebay.com.au","ebay.at","ebay.be","ebay.ca","ebay.ch","ebay.de","ebay.es","ebayanuncios.es","ebay.fr","ebay.ie","ebay.it","ebay.nl","ebay.co.uk","ebay.com","half.com"];for(d=0,f=b.length;d<f;d++){a=b[d];if(!(c===a||c.substring(c.length-a.length-1)==="."+a)){continue}switch(e["country"]){case"AT":e["code"]="5221-53469-19255-0";break;case"AU":e["code"]="705-53470-19255-0";break;case"BE":e["code"]="1553-53471-19255-0";break;case"CA":e["code"]="706-53473-19255-0";break;case"CH":e["code"]="5222-53480-19255-0";break;case"DE":e["code"]="707-53477-19255-0";break;case"ES":e["code"]="1185-53479-19255-0";break;case"FR":e["code"]="709-53476-19255-0";break;case"IE":e["code"]="5282-53468-19255-0";break;case"IT":e["code"]="724-53478-19255-0";break;case"NL":e["code"]="1346-53482-19255-0";break;case"UK":e["code"]="710-53481-19255-0";break;case"US":e["code"]="711-53200-19255-0"}if(c==="rover.ebay.com"){if(g["replace_links"]){j.href=j.href.replace(/campid=([0-9]+)/g,"campid="+e["campaign"]);j.href=j.href.replace(/rover\/1\/([0-9\-]+)/g,"rover/1/"+e["code"]);return true}else{return false}}if(c.substring(c.length-"half.com".length)==="half.com"){e["code"]="8971-56017-19255-0"}j.href="http://rover.ebay.com/rover/1/"+e["code"]+"/1?ff3=4&pub=5574962087&toolid=10001&campid="+e["campaign"]+"&customid=affililink&mpre="+encodeURIComponent(j.href);return true}}};b=function(a){var b,d,e,f;for(b in a){f=a[b];if(!(c===b||c.substring(c.length-b.length-1)==="."+b)){continue}if(!(b&&f)){return false}d=f.match(/([a-zA-Z0-9\-]+)=([a-zA-Z0-9\-]+)/);if(!d[2]){return false}e=new RegExp(d[1]+"=([a-zA-Z0-9-]+)");if(j.href.search(e)>-1){if(g["replace_links"]){j.href=j.href.replace(e,d[1]+"="+d[2]);return true}else{return false}}if(j.href.substring(j.href.length,j.href.length-1)==="/"){j.href+="?"+d[1]+"="+d[2];return true}if(j.href.match(/(\?)/)){j.href+="&"+d[1]+"="+d[2]}else{j.href+="/?"+d[1]+"="+d[2]}return true}};a=document.getElementsByTagName("a");f=window.location.hostname;m=[];for(k=0,l=a.length;k<l;k++){j=a[k];if(!(j.href.substring(0,7)==="http://"||j.href.substring(0,8)==="https://")){continue}c=j.href.split("/")[2];if(!c){continue}else{d();b(i);h()}}return m};if(window.attachEvent){window.attachEvent("onload",affililink)}else{if(window.onload){curronload=window.onload;newonload=function(){curronload;return affililink};window.onload=newonload}else{window.onload=affililink}}