Advertisement
Guest User

what does this JavaScript do?

a guest
Mar 5th, 2025
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const JS_VERSION="2025.03.04.2213",LASSO_JS_URL="https://js.getlasso.co",LASSO_API="https://lasso.link",LASSO_LINK_CLICK="Lasso Link Click",LASSO_DISPLAY_BOX="Lasso Display Primary Click",LASSO_DISPLAY_BOX_2ND="Lasso Display Secondary Click",LASSO_INTERNAL="Internal Click",LASSO_EXTERNAL="External Click",LASSO_CLICK_SUBID_PREFIX="LCID_",LASSO_REDIRECT_DOMAIN="https://go.lasso.link",LASSO_REDIRECT_AMAZON_URL="https://go.lasso.link/amazon",DISALLOWED_CHANGE_SUBID_AFFILIATES=["tradetracker"],LASSO_JSON_BOTS_URL=LASSO_JS_URL+"/bots.min.json",LASSO_JSON_AFFILIATES_URL=LASSO_JS_URL+"/affiliates.min.json",LASSO_JSON_IMPACT_DOMAINS_URL=LASSO_JS_URL+"/impact-domains.min.json",LASSO_JSON_AMAZON_DOMAINS_URL=LASSO_JS_URL+"/amazon-associates-domains.min.json",LASSO_ERROR_PREFIX="[Lasso] > ",SENTRY_URL="https://browser.sentry-cdn.com/9.1.0/bundle.tracing.min.js",SENTRY_DSN="https://[email protected]/4508838724501504";Object.hasOwn||(Object.hasOwn=function(t,r) {
  2.     return Object.prototype.hasOwnProperty.call(t,r);
  3. });
  4.  
  5. const LassoEvents= {
  6.     bots: null,params:null,lstracking:null,matching:1,priorityAffiliate:0,debug:0,affiliates:null,impactDomains:null,amazonDomains:null,unitTest:!1,setProperty:function(t,r){this[t]=r;
  7. },captureError:function(t,r="Error",e= {
  8. }){t="[Lasso] > "+t.toString(),r="[Lasso] > "+r.toString();const i=t instanceof Error?t:new Error(t);if(i.name=r,console.error(i),"undefined"==typeof Sentry)return;if((i.stack||"").includes("lasso-performance.")||this.unitTest) {
  9.     let t={params: e;
  10. };
  11.  
  12. Sentry.captureException(i, {
  13.     extra: {...t,timestamp:(new Date).toISOString();
  14. }})}
  15.  
  16. else this.log("Skipping non-Lasso error:",i);
  17. },rtrim:function(t,r="/") {
  18. try{return t.replace(new RegExp(r+"*$"),"");
  19. }
  20.  
  21. catch(t) {
  22. this.captureError(t,"Error in rtrim");
  23. }},isBot:function(t,r) {
  24. let e=!1;try{let i=this.bots;if(!i)return!1;for(let a=0;a{let s=i[a],n=s.url||null,o=s.regex||null;if(t&&n&&this.formatUrl(t).toLowerCase()===this.formatUrl(n).toLowerCase())return e=!0,!0;if(r&&o)try{if(new RegExp(o,"i").test(r))return e=!0,!0;
  25. }
  26.  
  27. catch(t) {
  28. let e={regexPattern: o,userAgent:r;
  29. };
  30.  
  31. this.captureError(t,"Error in isBot",e);
  32. }}
  33.  
  34. return e;
  35. }
  36.  
  37. catch(t) {
  38. return this.captureError(t,"Error in isBot"),e;
  39. }},getUTM:function() {
  40. let t={
  41. };
  42.  
  43. try {
  44. let r=window.location.search,e=new URLSearchParams(r).entries();for(const r of e){let e=r[0],i=r[1];0===e.indexOf("utm_")&&(t[e]=i);
  45. }
  46.  
  47. return t;
  48. }
  49.  
  50. catch(t) {
  51. this.captureError(t,"Error in getUTM");
  52. }
  53.  
  54. return t;
  55. },isValidHref:function(t) {
  56. if(!t||"string"!=typeof t)return!1;if((t=t.trim().toLocaleLowerCase()).startsWith("#")||t.startsWith("javascript:")||t.startsWith("mailto:")||t.startsWith("tel:")||t.startsWith("data:")||t.startsWith("/")||t.startsWith(":")||!t.startsWith("http://")&&!t.startsWith("https://"))return!1;try{new URL(t);
  57. }
  58.  
  59. catch(t) {
  60. return this.captureError(t,"Error in isValidHref"),!1;
  61. }
  62.  
  63. return!0;
  64. },getUrlParam:function(t,r) {
  65. try{if(!this.isValidHref(t))return null;return new URL(t).searchParams.get(r);
  66. }
  67.  
  68. catch(t) {
  69. this.captureError(t,"Error in getUrlParam");
  70. }
  71.  
  72. return null;
  73. },sendEvent:function(t,r,e) {
  74. try{const i=/^localhost$|^127(?: \.[0-9]+){0,2;
  75. }\.[0-9]+$|^(?:0*:)*?:?0*1$/.test(location.hostname)||"file:"===location.protocol;if(!r.trackLocalhost&&i&&!this.unitTest)return console.warn("[Lasso] Ignoring event because website is running locally");const a= {
  76. n: t,u:r.url,d:r.domain,r:r.referrer,w:r.deviceWidth,h:r.hashMode?1:0,p:e&&e.props?e.props:void 0;
  77. },s=new XMLHttpRequest;s.open("POST",r.apiHost+"/events/tracking",!0),s.setRequestHeader("Content-Type","text/plain"),s.send(JSON.stringify(a)),s.onreadystatechange=()=> {
  78. 4===s.readyState&&e&&e.callback&&e.callback();
  79. }}
  80.  
  81. catch(t) {
  82. this.captureError(t,"Error in sendEvent");
  83. }},LassoTracking:function(t) {
  84. try{const r=()=>Object.assign({hashMode: !1,trackLocalhost:!1,url:location.href,domain:location.hostname,referrer:document.referrer||null,deviceWidth:window.innerWidth,apiHost:"https://lasso.link";
  85. },t);return {
  86. trackEvent: (t,e,i)=>{this.sendEvent(t,Object.assign(Object.assign({
  87. },r()),i),e);
  88. }}}
  89.  
  90. catch(t) {
  91. this.captureError(t,"Error in LassoTracking");
  92. }
  93.  
  94. return null;
  95. },getPageLoadTime:function() {
  96. try{let t=window.performance.getEntriesByType("navigation"),r=0;return t.length>=1&&void 0!==t[0].domContentLoadedEventEnd&&(r=parseInt(t[0].domContentLoadedEventEnd)),r;
  97. }
  98.  
  99. catch(t) {
  100. this.captureError(t,"Error in getPageLoadTime");
  101. }
  102.  
  103. return 0;
  104. },getHierarchy:function(t,r=[]) {
  105. try{let e=t.localName,i=t.parentElement;if(!i||"body"==e)return r=r.join(" ");let a=t.getAttribute("class"),s=[],n="";a&&(s=a.split(" "),n="."+s.join("."));let o=e+n;return r.unshift(o),this.getHierarchy(i,r);
  106. }
  107.  
  108. catch(t) {
  109. this.captureError(t,"Error in getHierarchy");
  110. }
  111.  
  112. return null;
  113. },initLassoTracking:function(t) {
  114. try{window.lstracking=window.lstracking||this.lstracking;let t={lsid: this.params.lsid,pid:this.params.pid,ipa:this.params.ipa,d:location.origin,plt:this.getPageLoadTime(),utm:this.getUTM(),pt:document.title,pp:window.location.pathname,rh:this.sha256(document.body.innerHTML);
  115. };
  116.  
  117. if(this.log("Lasso Tracking is ready!"),!this.params.lsid)return;if(this.isBot(document.referrer||null,window.navigator.userAgent||null))return void console.warn("Bot request");this.lstracking.trackEvent("pageview", {
  118. props: t;
  119. })}
  120.  
  121. catch(t) {
  122. this.captureError(t,"Error in initLassoTracking");
  123. }},sendClickEvent:function(t,r,e) {
  124. try{let i=document.location.href,a=this.getUrlParam(i,"gclid"),s={lsid: this.params.lsid,pid:this.params.pid,ipa:this.params.ipa,gclid:a,d:location.origin,pt:document.title;
  125. };
  126.  
  127. return(t= {
  128. ...t,...s;
  129. }).type=r,delete t.event_category,delete t.event_label,t&&!this.isValidHref(t.lasso_href)?t:this.params.lsid?(t.lasso_href=this.addLassoClickIdToSubIDUrlArgument(t),t.js_version=JS_VERSION,t.js_matching=this.matching,e&&lstracking.trackEvent("click", {
  130. props: t;
  131. }),t):t;
  132. }
  133.  
  134. catch(t) {
  135. this.captureError(t,"Error in sendClickEvent");
  136. }
  137.  
  138. return t;
  139. },sendScrollDepthEvent:function(t,r) {
  140. try{let e={lsid: this.params.lsid,pid:this.params.pid,ipa:this.params.ipa,d:location.origin,pt:document.title,pp:window.location.pathname;
  141. };(t= {
  142. ...t,...e;
  143. }).type=r,lstracking.trackEvent("scroll", {
  144. props: t;
  145. })}
  146.  
  147. catch(t) {
  148. this.captureError(t,"Error in sendScrollDepthEvent");
  149. }},getEventName:function(t) {
  150. let r=LASSO_LINK_CLICK;try{let e=t.getAttribute("data-lasso-box-trackable"),i=t.getAttribute("data-lasso-name"),a=t.getAttribute("href"),s=t.classList;return r="true"===e?s.contains("lasso-button-2")?LASSO_DISPLAY_BOX_2ND: LASSO_DISPLAY_BOX:i&&"true"!==e?LASSO_LINK_CLICK:"string"==typeof a&&0===a.indexOf(location.origin)?LASSO_INTERNAL:LASSO_EXTERNAL,r;
  151. }
  152.  
  153. catch(t) {
  154. this.captureError(t,"Error in getEventName");
  155. }
  156.  
  157. return r;
  158. },getButtonText:function(t) {
  159. let r="",e=this.getEventName(t);try{let i=t.closest(".lasso-display");e===LASSO_LINK_CLICK?r=t.innerText: e===LASSO_DISPLAY_BOX?r=i.querySelector(".lasso-button-1").innerText:e===LASSO_DISPLAY_BOX_2ND?r=i.querySelector(".lasso-button-2").innerText:e===LASSO_EXTERNAL&&(r=t.innerText),""===r&&(r=t.innerText);
  160. }
  161.  
  162. catch(t) {
  163. r="",this.captureError(t,"Error in getButtonText");
  164. }
  165.  
  166. return r;
  167. },lassoClickTracking:function() {
  168. try{let t=this;this.log("Lasso click function"),document.addEventListener("click",(function(r){let e=r.target;if("a"!=e.localName&&(e=e.closest("a")),null===e)return;let i=e.getAttribute("data-lasso-id"),a=e.getAttribute("data-lasso-name"),s=e.getAttribute("class"),n=t.getEventName(e),o=t.getButtonText(e);o=o||a,o="string"==typeof o?o.trim(): "";
  169. let c=r.clientX,l=r.clientY,h=e.closest(".lasso-container"),u=h?h.querySelector(".lasso-badge"): null;
  170. if(u=u?u.innerText: "","a"==e.localName){let h=e.getAttribute("href"),f={lasso_title:a,lasso_href:h,lasso_text:o,lasso_badge:u,event_category:a,event_label:o;
  171. };
  172.  
  173. f.lasso_lid=i?parseInt(i):0,f.tag=e.localName,f.class=s,f.hierarchy=t.getHierarchy(e),f.cx=c,f.cy=l,f.sh=window.screen.height,f.sw=window.screen.width;let d=t.isLeanRedirect(h),p=!d,g=t.sendClickEvent(f,n,p),m=g.lasso_href;if(t.log("Lasso event sent: "+n+" || "+a),a&&(e.setAttribute("href",m),setTimeout((function(r,e) {
  174. e=t.appendParamsToUrl(e,{lcid: null;
  175. }),r.setAttribute("href",e);
  176. }),500,e,m)),d) {
  177. let i=e.getAttribute("data-lasso-link"),a=i||h;if(i){g.u=location.href;let r=t.matching?1: 0;
  178. a=LASSO_REDIRECT_AMAZON_URL+"?url="+encodeURIComponent(h)+"&matching="+r,a=t.appendParamsToUrl(a,g);
  179. }"_blank"===e.target?window.open(a,"_blank"):window.location.assign(a),r.preventDefault();
  180. }}}))}
  181.  
  182. catch(t) {
  183. this.captureError(t,"Error in lassoClickTracking");
  184. }},lassoDetectLinks:function() {
  185. try{if(this.log("Lasso matching",this.matching),!this.matching)return;const t=this,r=document.links.length;for(let e=0;e{let r=document.links[e],i=r.href;if(""!==i&&!/^#/.test(i)&&(t.isAmazonLink(i)&&t.getAmazonProductId(i)||t.isAmazonShortLink(i))){t.removeOtherRedirectsPlugins(r);let e=LASSO_REDIRECT_AMAZON_URL+"?url="+encodeURIComponent(i);r.setAttribute("data-lasso-link",e);
  186. }}}
  187.  
  188. catch(t) {
  189. this.captureError(t,"Error in lassoDetectLinks");
  190. }},enableTrackingGTM:function() {
  191. try{this.enableTrackingGAv4(!0);
  192. }
  193.  
  194. catch(t) {
  195. this.captureError(t,"Error in enableTrackingGTM");
  196. }},enableTrackingGAv4:function(t=!1) {
  197. try{let r=this;this.log("Lasso GA function gtag"),document.addEventListener("click",(function(e){let i=e.target;if("a"!=i.localName&&(i=i.closest("a")),null===i)return;let a=i.getAttribute("data-lasso-name"),s=r.getEventName(i),n=r.getButtonText(i);n=n||a,n="string"==typeof n?n.trim(): "";
  198. let o=i.closest(".lasso-container"),c=o?o.querySelector(".lasso-badge"): null;
  199. if(c=c?c.innerText: "","a"==i.localName){let e={lasso_title:a,lasso_href:i.getAttribute("href"),lasso_text:n,lasso_badge:c,event:s,event_type:s,event_category:a,event_label:n;
  200. };
  201.  
  202. a&&(t?dataLayer.push(e):gtag("event",s,e),r.log("Lasso GA event sent: "+s+" || "+a));
  203. }}))}
  204.  
  205. catch(t) {
  206. this.captureError(t,"Error in enableTrackingGAv4");
  207. }},enableTrackingGA:function() {
  208. try{let t=this;this.log("Lasso GA click"),document.addEventListener("click",(function(r){let e=r.target;if("a"!=e.localName&&(e=e.closest("a")),null===e)return;let i=e.getAttribute("data-lasso-id"),a=e.getAttribute("data-lasso-name"),s=t.getEventName(e);if("a"==e.localName&&i&&a){let r=e.getAttribute("href");void 0!==ga.getByName("LassoTracker")?(t.log("lasso ga with tracker"),ga("LassoTracker.send","event",a,s,r)): (t.log("lasso ga without tracker"),ga("send","event",a,s,r)),t.log("Lasso GA event sent");
  209. }}))}
  210.  
  211. catch(t) {
  212. this.captureError(t,"Error in enableTrackingGA");
  213. }},lsSetCookie:function(t,r,e) {
  214. try{var i="";if(e){var a=new Date;a.setTime(a.getTime()+24*e*60*60*1e3),i="; expires="+a.toUTCString();
  215. }
  216.  
  217. document.cookie=t+"="+(r||"")+i+"; path=/";
  218. }
  219.  
  220. catch(t) {
  221. this.captureError(t,"Error in lsSetCookie");
  222. }},lsGetCookie:function(t) {
  223. for(var r=t+"=",e=document.cookie.split(";"),i=0;i{for(var a=e[i];" "==a.charAt(0);)a=a.substring(1,a.length);if(0==a.indexOf(r))return a.substring(r.length,a.length);
  224. }
  225.  
  226. return null;
  227. },docReady:function(t) {
  228. try{this.log(document.readyState),this.log(document.addEventListener),"complete"===document.readyState||"undefined"!=typeof lassoHtmlLoaded&&!0===lassoHtmlLoaded?t(): document.addEventListener?document.addEventListener("DOMContentLoaded",t):document.attachEvent("onreadystatechange",(function(){"complete"===document.readyState&&t();
  229. }))}
  230.  
  231. catch(t) {
  232. this.captureError(t,"Error in docReady");
  233. }},generateId:function(t) {
  234. try{let r="";const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e.length;let a=0;for(;a;)r+=e.charAt(Math.floor(Math.random()*i)),a+=1;return r;
  235. }
  236.  
  237. catch(t) {
  238. this.captureError(t,"Error in generateId");
  239. }},init:function(t= {
  240. }){try {
  241. if("true"===document.getElementsByTagName("body")[0].getAttribute("lsevent"))return;document.getElementsByTagName("body")[0].setAttribute("lsevent","true"),this.debug=t.debug||this.debug,this.debug="1"===this.debug||1===this.debug,this.log("Lasso GA is ready!"),t.lsid=t.lsid?t.lsid: "lsp-"+this.generateId(40);
  242. let r=this.lsGetCookie("lsid");if(!r){let e=1;this.lsSetCookie("lsid",t.lsid,e),r=this.lsGetCookie("lsid");
  243. }
  244.  
  245. t.lsid=r,t.pid=t.pid||0,t.performance=parseInt(t.performance||1),this.params=t,this.lstracking=this.LassoTracking( {
  246. apiHost: LASSO_API;
  247. }),Object.hasOwn(t,"lssid")&&void 0!==t.lssid&&null!==t.lssid&&""!==t.lssid?this.matching=1:(this.matching=t.matching||this.matching,this.matching="1"===this.matching||1===this.matching),this.log("Lasso matching",this.matching),this.priorityAffiliate=t.priority_affiliate||this.priorityAffiliate,this.priorityAffiliate="1"===this.priorityAffiliate||1===this.priorityAffiliate,"function"==typeof gtag?this.enableTrackingGAv4():"function"==typeof tag?this.enableTrackingGA():"object"==typeof dataLayer&&this.enableTrackingGTM(),1===t.performance&&(this.initLassoTracking(),this.lassoClickTracking(),this.lassoDetectLinks());
  248. }
  249.  
  250. catch(t) {
  251. this.captureError(t,"Error in init");
  252. }},debounce:function(t,r) {
  253. try{let e;return function(...i){clearTimeout(e),e=setTimeout((function(){t(...i);
  254. }),r);
  255. }}
  256.  
  257. catch(t) {
  258. this.captureError(t,"Error in debounce");
  259. }},addLassoClickIdToSubIDUrlArgument:function(t) {
  260. try{let r=t.lasso_href,e=t.lasso_title,i=this.isAffiliate(r),a=this.buildLassoSubID();if(i&&!DISALLOWED_CHANGE_SUBID_AFFILIATES.includes(i)){let t=this.getAffiliateSubID(i,r),e=Object.keys(t),s=e[e.length-1];if(1===e.length){let r=e[0];t[r]=t[r].replace(/__LCID_\w{10;
  261. }/g,""),t[r]=t[r].replace(/LCID_\w {
  262. 10;
  263. }/g,""),t[r]=""!==t[r]?t[r]+"__"+a:a;
  264. }
  265.  
  266. else for(let r in t) {
  267. if(""!==t[r]&&t[r].includes("__LCID_")){let e=t[r].split("__LCID_");t[r]=e[0]+"__"+a;break;
  268. }
  269.  
  270. if(""===t[r]||t[r].includes("LCID_")) {
  271. t[r]=a;break;
  272. }
  273.  
  274. if(s===r) {
  275. t[r]=t[r].replace(/__LCID_\w{10;
  276. }/g,""),t[r]=t[r].replace(/LCID_\w {
  277. 10;
  278. }/g,""),t[s]=t[r]+"__"+a;break;
  279. }}
  280.  
  281. r=this.appendParamsToUrl(r,t);
  282. }
  283.  
  284. else if(e) {
  285. this.getBaseDomain(location.hostname)===this.getBaseDomain(r)&&(r=this.appendParamsToUrl(r,{lcid: a;
  286. }))}
  287.  
  288. return r;
  289. }
  290.  
  291. catch(r) {
  292. return this.captureError(r,"Error in addLassoClickIdToSubIDUrlArgument"),t.lasso_href;
  293. }},buildLassoSubID:function(t=10) {
  294. try{const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",e=r.length;let i="";for(;i.length{i+=r[Math.floor(Math.random()*e)];
  295. }
  296.  
  297. return"LCID_"+i.substring(0,t);
  298. }
  299.  
  300. catch(t) {
  301. this.captureError(t,"Error in buildLassoSubID");
  302. }},isAffiliate:function(t) {
  303. try{let r=this;if(!this.affiliates)return!1;for(const e in this.affiliates)if(Object.hasOwn(this.affiliates,e)&&r[this.affiliates[e].is_affiliate_function](t))return this.affiliates[e].slug;return!1;
  304. }
  305.  
  306. catch(t) {
  307. return this.captureError(t,"Error in isAffiliate"),!1;
  308. }},getAffiliateSubID:function(t,r) {
  309. try{if(!this.affiliates)return{
  310. };
  311.  
  312. let e=this.affiliates[t].sub_ids,i= {
  313. };
  314.  
  315. for(const t of e)i[t]="";let a=this.getQueryParameters(r);for(let t in a)e.includes(t)&&""!==a[t]&&(i[t]=a[t]);return i;
  316. }
  317.  
  318. catch(t) {
  319. return this.captureError(t,"Error in getAffiliateSubID"),{
  320. }}},check_regex:function(t,r) {
  321. try{t=t.replace(/^\/|\/$/g,"");let e=new RegExp(t,"g");return r.match(e);
  322. }
  323.  
  324. catch(t) {
  325. return this.captureError(t,"Error in check_regex"),!1;
  326. }},is_awin:function(t) {
  327. try{return!!this.affiliates&&this.check_regex(this.affiliates.awin.matches,t);
  328. }
  329.  
  330. catch(t) {
  331. return this.captureError(t,"Error in is_awin"),!1;
  332. }},is_cj:function(t) {
  333. try{return!!this.affiliates&&this.check_regex(this.affiliates.cj.matches,t);
  334. }
  335.  
  336. catch(t) {
  337. return this.captureError(t,"Error in is_cj"),!1;
  338. }},is_financeAds:function(t) {
  339. try{return!!this.affiliates&&this.check_regex(this.affiliates.financeads.matches,t);
  340. }
  341.  
  342. catch(t) {
  343. return this.captureError(t,"Error in is_financeAds"),!1;
  344. }},is_impact:function(t) {
  345. try{if(!this.impactDomains)return!1;let r=this.getBaseDomain(t),e=this.getBaseDomain(t,!1);return Object.hasOwn(this.impactDomains,r)||Object.hasOwn(this.impactDomains,e);
  346. }
  347.  
  348. catch(t) {
  349. return this.captureError(t,"Error in is_impact"),!1;
  350. }},is_shareasale:function(t) {
  351. try{return!!this.affiliates&&this.check_regex(this.affiliates.shareasale.matches,t);
  352. }
  353.  
  354. catch(t) {
  355. return this.captureError(t,"Error in is_shareasale"),!1;
  356. }},is_amazon:function(t) {
  357. try{if(!this.amazonDomains)return!1;let r=this.getBaseDomain(t);return Object.hasOwn(this.amazonDomains,r);
  358. }
  359.  
  360. catch(t) {
  361. return this.captureError(t,"Error in is_amazon"),!1;
  362. }},is_partnerize:function(t) {
  363. try{return!!this.affiliates&&this.check_regex(this.affiliates.partnerize.matches,t);
  364. }
  365.  
  366. catch(t) {
  367. return this.captureError(t,"Error in is_partnerize"),!1;
  368. }},is_flexoffers:function(t) {
  369. try{return!!this.affiliates&&this.check_regex(this.affiliates.flexoffers.matches,t);
  370. }
  371.  
  372. catch(t) {
  373. return this.captureError(t,"Error in is_flexoffers"),!1;
  374. }},is_refersion:function(t) {
  375. try{return!!this.affiliates&&this.check_regex(this.affiliates.refersion.matches,t);
  376. }
  377.  
  378. catch(t) {
  379. return this.captureError(t,"Error in is_refersion"),!1;
  380. }},is_post_affiliate_pro:function(t) {
  381. try{if(!this.isValidHref(t))return!1;let r=new URL(t);const e=/(a_aid=.+)|(tr_aid=.+)/,i=/repfitness\.com/,a=/\.ivacy.com/,s=/(\.postaffiliatepro|affiliates\.xeroshoes)\.com\/scripts\//,n=/a_aid|tr_aid|a_bid/;return!!(r.hash.match(e)||r.origin.match(i)||r.origin.match(a)||r.href.match(s)||r.search.match(n));
  382. }
  383.  
  384. catch(t) {
  385. return this.captureError(t,"Error in is_post_affiliate_pro"),!1;
  386. }},is_avantlink:function(t) {
  387. try{return!!this.affiliates&&this.check_regex(this.affiliates.avantlink.matches,t);
  388. }
  389.  
  390. catch(t) {
  391. return this.captureError(t,"Error in is_avantlink"),!1;
  392. }},is_pepperjam:function(t) {
  393. try{return!!this.affiliates&&this.check_regex(this.affiliates.pepperjam.matches,t);
  394. }
  395.  
  396. catch(t) {
  397. return this.captureError(t,"Error in is_pepperjam"),!1;
  398. }},is_everflow:function(t) {
  399. try{return!!this.affiliates&&this.check_regex(this.affiliates.everflow.matches,t);
  400. }
  401.  
  402. catch(t) {
  403. return this.captureError(t,"Error in is_everflow"),!1;
  404. }},is_tune:function(t) {
  405. try{return!!this.affiliates&&this.check_regex(this.affiliates.tune.matches,t);
  406. }
  407.  
  408. catch(t) {
  409. return this.captureError(t,"Error in is_tune"),!1;
  410. }},is_partnerstack:function(t) {
  411. try{return!!this.affiliates&&this.check_regex(this.affiliates.partnerstack.matches,t);
  412. }
  413.  
  414. catch(t) {
  415. return this.captureError(t,"Error in is_partnerstack"),!1;
  416. }},is_goaffpro:function(t) {
  417. try{return!!this.affiliates&&this.check_regex(this.affiliates.goaffpro.matches,t);
  418. }
  419.  
  420. catch(t) {
  421. return this.captureError(t,"Error in is_goaffpro"),!1;
  422. }},is_aragon:function(t) {
  423. try{return!!this.affiliates&&this.check_regex(this.affiliates.aragon.matches,t);
  424. }
  425.  
  426. catch(t) {
  427. return this.captureError(t,"Error in is_aragon"),!1;
  428. }},is_sovrn:function(t) {
  429. try{return!!this.affiliates&&this.check_regex(this.affiliates.sovrn.matches,t);
  430. }
  431.  
  432. catch(t) {
  433. return this.captureError(t,"Error in is_sovrn"),!1;
  434. }},is_rakuten:function(t) {
  435. try{return!!this.affiliates&&this.check_regex(this.affiliates.rakuten.matches,t);
  436. }
  437.  
  438. catch(t) {
  439. return this.captureError(t,"Error in is_rakuten"),!1;
  440. }},is_skimlinks:function(t) {
  441. try{return!!this.affiliates&&this.check_regex(this.affiliates.skimlinks.matches,t);
  442. }
  443.  
  444. catch(t) {
  445. return this.captureError(t,"Error in is_skimlinks"),!1;
  446. }},is_agoda:function(t) {
  447. try{return!!this.affiliates&&this.check_regex(this.affiliates.agoda.matches,t);
  448. }
  449.  
  450. catch(t) {
  451. return this.captureError(t,"Error in is_agoda"),!1;
  452. }},is_bol:function(t) {
  453. try{return!!this.affiliates&&this.check_regex(this.affiliates.bol.matches,t);
  454. }
  455.  
  456. catch(t) {
  457. return this.captureError(t,"Error in is_bol"),!1;
  458. }},is_booking:function(t) {
  459. try{return!!this.affiliates&&this.check_regex(this.affiliates.booking.matches,t);
  460. }
  461.  
  462. catch(t) {
  463. return this.captureError(t,"Error in is_booking"),!1;
  464. }},is_cake:function(t) {
  465. try{return!!this.affiliates&&this.check_regex(this.affiliates.cake.matches,t);
  466. }
  467.  
  468. catch(t) {
  469. return this.captureError(t,"Error in is_cake"),!1;
  470. }},is_clickbank:function(t) {
  471. try{return!!this.affiliates&&this.check_regex(this.affiliates.clickbank.matches,t);
  472. }
  473.  
  474. catch(t) {
  475. return this.captureError(t,"Error in is_clickbank"),!1;
  476. }},is_commission_factory:function(t) {
  477. try{return!!this.affiliates&&this.check_regex(this.affiliates.commission_factory.matches,t);
  478. }
  479.  
  480. catch(t) {
  481. return this.captureError(t,"Error in is_commission_factory"),!1;
  482. }},is_daisycon:function(t) {
  483. try{return!!this.affiliates&&this.check_regex(this.affiliates.daisycon.matches,t);
  484. }
  485.  
  486. catch(t) {
  487. return this.captureError(t,"Error in is_daisycon"),!1;
  488. }},is_ebay:function(t) {
  489. try{return!!this.affiliates&&this.check_regex(this.affiliates.ebay.matches,t);
  490. }
  491.  
  492. catch(t) {
  493. return this.captureError(t,"Error in is_ebay"),!1;
  494. }},is_firstpromoter:function(t) {
  495. try{return!!this.affiliates&&this.check_regex(this.affiliates.firstpromoter.matches,t);
  496. }
  497.  
  498. catch(t) {
  499. return this.captureError(t,"Error in is_firstpromoter"),!1;
  500. }},is_get_your_guide:function(t) {
  501. try{return!!this.affiliates&&this.check_regex(this.affiliates.get_your_guide.matches,t);
  502. }
  503.  
  504. catch(t) {
  505. return this.captureError(t,"Error in is_get_your_guide"),!1;
  506. }},is_idevaffiliate:function(t) {
  507. try{return!!this.affiliates&&this.check_regex(this.affiliates.idevaffiliate.matches,t);
  508. }
  509.  
  510. catch(t) {
  511. return this.captureError(t,"Error in is_idevaffiliate"),!1;
  512. }},is_linkconnector:function(t) {
  513. try{return!!this.affiliates&&this.check_regex(this.affiliates.linkconnector.matches,t);
  514. }
  515.  
  516. catch(t) {
  517. return this.captureError(t,"Error in is_linkconnector"),!1;
  518. }},is_maxbounty:function(t) {
  519. try{return!!this.affiliates&&this.check_regex(this.affiliates.maxbounty.matches,t);
  520. }
  521.  
  522. catch(t) {
  523. return this.captureError(t,"Error in is_maxbounty"),!1;
  524. }},is_rentalcarscom:function(t) {
  525. try{return!!this.affiliates&&this.check_regex(this.affiliates.rentalcarscom.matches,t);
  526. }
  527.  
  528. catch(t) {
  529. return this.captureError(t,"Error in is_rentalcarscom"),!1;
  530. }},is_tradedoubler:function(t) {
  531. try{return!!this.affiliates&&this.check_regex(this.affiliates.tradedoubler.matches,t);
  532. }
  533.  
  534. catch(t) {
  535. return this.captureError(t,"Error in is_tradedoubler"),!1;
  536. }},is_tradetracker:function(t) {
  537. try{return!!this.affiliates&&this.check_regex(this.affiliates.tradetracker.matches,t);
  538. }
  539.  
  540. catch(t) {
  541. return this.captureError(t,"Error in is_tradetracker"),!1;
  542. }},is_webgains:function(t) {
  543. try{return!!this.affiliates&&this.check_regex(this.affiliates.webgains.matches,t);
  544. }
  545.  
  546. catch(t) {
  547. return this.captureError(t,"Error in is_webgains"),!1;
  548. }},sha256:function(t) {
  549. try{const i=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function r(t,r){return t>>>r|t<<32-r;
  550. }
  551.  
  552. function e(t,e) {
  553. const a=new Uint32Array(64);for(let r=0;r<16;r++)a[r]=t[4*r]<<24|t[4*r+1]<<16|t[4*r+2]<<8|t[4*r+3];for(let t=16;t<64;t++){const e=r(a[t-15],7)^r(a[t-15],18)^a[t-15]>>>3,i=r(a[t-2],17)^r(a[t-2],19)^a[t-2]>>>10;a[t]=a[t-16]+e+a[t-7]+i>>>0;
  554. }
  555.  
  556. let s=e[0],n=e[1],o=e[2],c=e[3],l=e[4],h=e[5],u=e[6],f=e[7];for(let t=0;t<64;t++) {
  557. const e=f+(r(l,6)^r(l,11)^r(l,25))+(l&h^~l&u)+i[t]+a[t]>>>0,d=s&n^s&o^n&o;f=u,u=h,h=l,l=c+e>>>0,c=o,o=n,n=s,s=e+((r(s,2)^r(s,13)^r(s,22))+d>>>0)>>>0;
  558. }
  559.  
  560. e[0]=e[0]+s>>>0,e[1]=e[1]+n>>>0,e[2]=e[2]+o>>>0,e[3]=e[3]+c>>>0,e[4]=e[4]+l>>>0,e[5]=e[5]+h>>>0,e[6]=e[6]+u>>>0,e[7]=e[7]+f>>>0;
  561. }
  562.  
  563. const a=(new TextEncoder).encode(t),s=64*Math.ceil((a.length+9)/64),n=new Uint8Array(s);n.set(a),n[a.length]=128,n[s-4]=8*a.length>>>24&255,n[s-3]=8*a.length>>>16&255,n[s-2]=8*a.length>>>8&255,n[s-1]=8*a.length&255;const o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);for(let t=0;t;t+=64)e(n.subarray(t,t+64),o);return o.reduce((t,r)=>t+r.toString(16).padStart(8,"0"),"");
  564. }
  565.  
  566. catch(t) {
  567. return this.captureError(t,"Error in sha256"),!1;
  568. }},isAmazonLink:function(t) {
  569. try{return!!t&&t.includes("amazon.");
  570. }
  571.  
  572. catch(t) {
  573. return this.captureError(t,"Error in isAmazonLink"),!1;
  574. }},isAmazonShortLink:function(t) {
  575. try{return/^https?: \/\/amzn\.to\/[A-Za-z0-9]+\/?$/.test(t);
  576. }
  577.  
  578. catch(t) {
  579. return this.captureError(t,"Error in isAmazonShortLink"),!1;
  580. }},getAmazonProductId:function(t) {
  581. try{let r=!1;if(t=this.formatUrl(t,!1),!this.isValidHref(t))return!1;const e=new URL(t),i=e.pathname.replace(/[^A-Za-z0-9\/\: ]+/g,""),a=`${e.protocol;
  582. }//${e.hostname;
  583. }${i;
  584. }`,s=`$ {
  585. e.protocol;
  586. }//${e.hostname;
  587. }`,n=/https?:\/\/(?:www\.)?amazon\.[a-z\.]+\/(?:[\w-]+\/)?(?:gp\/aw\/d|d\/[\w-]+\/[\w-]+|dp|dp\/product|gp\/product|ASIN|gp\/video\/detail|exec\/obidos\/ASIN|hz\/audible\/mlp\/mfpdp|gp\/offerlisting)\/([A-Z0-9] {
  588. 10;
  589. })/i,o=t.match(n);if(o&&(r=o[1]),!r) {
  590. const t=new RegExp(s+"(?:/[a-z]+)?/([\\w-]+/)?(gp/aw/d|d/[\\w-]+/[\\w-]+|dp|dp/product|gp/product|ASIN|gp/video/detail|exec/obidos/ASIN|hz/audible/mlp/mfpdp|gp/offerlisting)/(\\w+)?(\\w{10})(/)?"),e=a.match(t);e&&(r=e[4]);
  591. }
  592.  
  593. if(!1!==r&&r.includes("?")) {
  594. const t=r.split("?");r=t.length>0?t[0]: r;
  595. }
  596.  
  597. return!1!==r&&(r=r.toUpperCase()),r;
  598. }
  599.  
  600. catch(t) {
  601. return this.captureError(t,"Error in getAmazonProductId"),!1;
  602. }},formatUrl:function(t,r=!0) {
  603. try{if(!t||!this.isValidHref(t))return t;const e=new URL(t),i=e.protocol.replace(":",""),a=e.search||"",s=e.port||"",n=e.hash||"";let o=`${i;
  604. }
  605.  
  606. ://$ {
  607. e.hostname;
  608. }${s?":"+s:"";
  609. }${e.pathname;
  610. }${n;
  611. }`;
  612.  
  613. return r&&a&&(o+=""+a),o;
  614. }
  615.  
  616. catch(r) {
  617. return this.captureError(r,"Error in formatUrl"),t;
  618. }},appendParamsToUrl:function(t,r) {
  619. try{const[e,i]=t.split("?"),a=new URLSearchParams(i||"");return Object.entries(r).forEach(([t,r])=>{null!==r&&""!==r&&void 0!==r&&"undefined"!==r?a.set(t,r): a.delete(t);
  620. }),`${e;
  621. }?${a.toString();
  622. }`}
  623.  
  624. catch(r) {
  625. return this.captureError(r,"Error in appendParamsToUrl"),t;
  626. }},getBaseDomain:function(t,r=!0) {
  627. try{t=t.replace(/^(https?: \/\/)?(www\.)?/,"");
  628. let e=t.split("/")[0];if(!r){const t=e.split(".");t.length>2&&(e=t.slice(1).join("."));
  629. }
  630.  
  631. return e;
  632. }
  633.  
  634. catch(t) {
  635. return this.captureError(t,"Error in getBaseDomain"),"";
  636. }},getQueryParameters:function(t) {
  637. try{const r={
  638. };
  639.  
  640. return new URL(t).searchParams.forEach((t,e)=> {
  641. r[e]=t;
  642. }),r;
  643. }
  644.  
  645. catch(t) {
  646. return this.captureError(t,"Error in getQueryParameters"),{
  647. }}},log:function(...t) {
  648. try{this.debug&&console.log(...t);
  649. }
  650.  
  651. catch(t) {
  652. this.captureError(t,"Error in log");
  653. }},removeOtherRedirectsPlugins:function(t) {
  654. try{t.removeAttribute("data-geniuslink"),t.onclick=null;
  655. }
  656.  
  657. catch(t) {
  658. this.captureError(t,"Error in removeOtherRedirectsPlugins");
  659. }},isLeanRedirect:function(t) {
  660. try{if(!this.matching)return!1;let r=Boolean(this.isAmazonLink(t)&&this.getAmazonProductId(t)||this.isAmazonShortLink(t)),e=r,i=null!==this.getUrlParam(t,"aa_campaignid")&&r;return e&&i&&(e=this.priorityAffiliate),e;
  661. }
  662.  
  663. catch(t) {
  664. return this.captureError(t,"Error in isLeanRedirect"),!1;
  665. }}},loadJSON=t=>new Promise((r,e)=> {
  666. try{const i=new XMLHttpRequest;i.onreadystatechange=function(){if(this.readyState===this.DONE)if(200===this.status)try{const t=JSON.parse(this.responseText);r(t);
  667. }
  668.  
  669. catch(t) {
  670. e(new Error("Failed to parse JSON"));
  671. }
  672.  
  673. else e(new Error("HTTP error! status: "+this.status));
  674. },i.onerror=()=>e(new Error("Network error")),i.open("GET",t,!0),i.send(null);
  675. }
  676.  
  677. catch(r) {
  678. console.error("Error in loadJSON: "+t,r),e(r);
  679. }}),loadSentryScript=()=>new Promise((t,r)=> {
  680. try{const e=document.createElement("script");e.src=SENTRY_URL,e.crossOrigin="anonymous",e.onload=()=>{"undefined"!=typeof Sentry?(Sentry.init({dsn: SENTRY_DSN,tracesSampleRate:.1,beforeSend(t){if(t.exception){const r=t.exception.values[0];
  681. let e=0===r.type.indexOf("[Lasso] > "),i=0===r.value.indexOf("[Lasso] > ");if(!(e&&i))return null;
  682. }
  683.  
  684. return t;
  685. },release:"lasso@"+JS_VERSION,environment:"production";
  686. }),t()):r(new Error("Sentry failed to initialize"));
  687. },e.onerror=()=>r(new Error("Failed to load Sentry script")),document.head.appendChild(e);
  688. }
  689.  
  690. catch(t) {
  691. console.error(t,"Error in loadSentryScript");
  692. }}),lassoLoadSentry=async()=> {
  693. document.addEventListener("DOMContentLoaded",async()=>{try{const t=await loadJSON(LASSO_JSON_BOTS_URL);t&&(LassoEvents.bots=t);const r=await loadJSON(LASSO_JSON_AFFILIATES_URL);r&&(LassoEvents.affiliates=r);const e=await loadJSON(LASSO_JSON_IMPACT_DOMAINS_URL);e&&(LassoEvents.impactDomains=e);const i=await loadJSON(LASSO_JSON_AMAZON_DOMAINS_URL);i&&(LassoEvents.amazonDomains=i),await new Promise((t,r)=>{try{const e=document.createElement("script");e.src=SENTRY_URL,e.crossOrigin="anonymous",e.onload=()=>{"undefined"!=typeof Sentry?(Sentry.init({dsn: SENTRY_DSN,tracesSampleRate:.1,beforeSend(t){if(t.exception){const r=t.exception.values[0];
  694. let e=0===r.type.indexOf("[Lasso] > "),i=0===r.value.indexOf("[Lasso] > ");if(!e||!i)return null;
  695. }
  696.  
  697. return t;
  698. },release:"lasso@"+JS_VERSION,environment:"production";
  699. }),t()):r(new Error("Sentry failed to initialize"));
  700. },e.onerror=()=>r(new Error("Failed to load Sentry script")),document.head.appendChild(e);
  701. }
  702.  
  703. catch(t) {
  704. console.error(t,"Error in loadSentryScript");
  705. }});
  706.  
  707. const a=new CustomEvent("lassoTrackingEventLoaded", {
  708. detail: LassoEvents;
  709. });
  710.  
  711. document.dispatchEvent(a);
  712. }
  713.  
  714. catch(t) {
  715. console.log("Error loading Sentry:",t);
  716. }})};
  717.  
  718. lassoLoadSentry(),"undefined"!=typeof module&&module.exports&&(module.exports= {
  719. LassoEvents: LassoEvents,LASSO_REDIRECT_AMAZON_URL:LASSO_REDIRECT_AMAZON_URL,JS_VERSION:JS_VERSION;
  720. });
  721.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement