Skip to content

Instantly share code, notes, and snippets.

@raymondctc
Created April 24, 2019 02:16
Show Gist options
  • Save raymondctc/49e9721bc1bae7a997cecb87261b9d4b to your computer and use it in GitHub Desktop.
Save raymondctc/49e9721bc1bae7a997cecb87261b9d4b to your computer and use it in GitHub Desktop.
test.html
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title></head><body><script type="text/javascript">var additionalReports=window.additionalReports||{};additionalReports.ReportingManager=function(){this.brdUrl="https://www.hktvmall.com/hktv/zh/main/Kimberly-Clark-Family-Care-Store/s/H0551003/%E8%B6%85%E7%B4%9A%E5%B7%BF%E5%A0%B4/%E8%B6%85%E7%B4%9A%E5%B8%82%E5%A0%B4/%E7%B4%99%E5%93%81-%E5%8D%B3%E6%A3%84%E5%93%81-%E5%AE%B6%E5%B1%85%E7%94%A8%E5%93%81/%E6%BF%95%E7%B4%99%E5%B7%BE/%E6%BF%95%E5%BB%81%E7%B4%9940%E7%89%87%E8%A3%9C%E5%85%85%E8%A3%9D/p/H0888001_S_10050049?utm_source=merchant_kc&utm_medium=gdn_300x250&utm_campaign=andrex_mbt&utm_term=affinity&utm_content=general&autoTriggerApp=true",this.clickThroughUrls=[],this.networkUrl="",this.defaultClickUrl=[],this.clickVersionUrl=[],this.networkUrl.length>0&&(this.clickThroughUrls[this.clickThroughUrls.length]=this.networkUrl),this.clickVersionUrl.length>0&&(this.clickThroughUrls=this.clickThroughUrls.concat(this.clickVersionUrl)),this.defaultClickUrl.length>0&&(this.clickThroughUrls=this.clickThroughUrls.concat(this.defaultClickUrl)),this.clickUrlNum=this.clickThroughUrls.length,this.flags=this._getFlags()},additionalReports.ReportingManager.prototype={clickUrlCounter:0,clickUrlNum:0,clickThroughUrls:[],networkUrl:"",brdUrl:"",clickReported:!1,clickVersionUrl:"",defaultClickUrl:"",_addEventListener:function(t,i,r){var e=window.document.getElementById(t);e&&(window.addEventListener?e.addEventListener(i,r,!1):window.attachEvent&&e.attachEvent("on"+i,r))},_getFlags:function(){var t,i,r=window.location.search.substring(1).split("&");for(t=0;t<r.length;t++)if("cff"==(i=r[t].split("="))[0])try{return JSON.parse(decodeURIComponent(i[1]))}catch(t){}return{}},_getRandomNumber:function(){var t="";try{t=Math.random().toString(),t=t.substr(t.indexOf(".")+1)}catch(i){t=""}return t},_allImagesAreLoaded:function(){++this.clickUrlCounter==this.clickUrlNum&&this.brdUrl&&this._windowRedirect()},_windowRedirect:function(){if(!this.clickReported&&this.brdUrl&&window&&window.document&&window.document.location){this.clickReported=!0;this.brdUrl.match("^[^?]*:.*")||(this.brdUrl="http://"+this.brdUrl);var t=!1;if(this.flags.UnldEv&&window.addEventListener("beforeunload",function(i){t=!0}),window.document.location.replace(this.brdUrl),this.flags.LocTO){var i=this.brdUrl;setTimeout(function(){t||window.document.location.replace(i)},5)}}},_createReportingImage:function(t){var i=window.document.createElement("img");return i.style.height="1px",i.style.width="1px",i.setAttribute("id","img"+t),i},_setImageSource:function(t){var i=document.getElementById("img"+t);document.documentMode&&document.documentMode<8?i.src=this.clickThroughUrls[t]:i.setAttribute("src",this.clickThroughUrls[t])},_runReportingFlow:function(){var t=[];if(this.clickThroughUrls&&this.clickThroughUrls.length>0){this.clickUrlCounter=0;try{if(window&&window.document&&window.document.body){for(var i=window.document,r=this,e=function(){r._allImagesAreLoaded()},n=0;n<this.clickUrlNum;n++)try{t[n]=this._createReportingImage(n),i.body.appendChild(t[n]),this._addEventListener("img"+n,"error",e),this._addEventListener("img"+n,"load",e),this._setImageSource(n)}catch(t){e()}setTimeout(function(){r._windowRedirect()},1e3)}}catch(t){}}else this._windowRedirect()}},window.additionalReports.reportMgr=new additionalReports.ReportingManager,window.additionalReports.reportMgr._runReportingFlow();</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment