d1639lhkj5l89m.cloudfront.net
Open in
urlscan Pro
2600:9000:214f:e00:17:407b:8680:21
Public Scan
URL:
https://d1639lhkj5l89m.cloudfront.net/js/script_tag/new/sca_affiliate_new.js?shop=juicefly.myshopify.com
Submission: On April 04 via manual from US — Scanned from DE
Submission: On April 04 via manual from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
class Uppromote{constructor(e="production",t=!0){this.env=e,this.host=({dev:"https://secomapp-affiliate.test",test:"https://af-test.uppromote.com",production:"https://track.uppromote.com"})[e]||"https://track.uppromote.com",this.cdnHost=({dev:"https://secomapp-affiliate.test",test:"https://af-test.uppromote.com",production:"https://d1639lhkj5l89m.cloudfront.net"})[e]||"https://d1639lhkj5l89m.cloudfront.net",this.cdnS3Host=({dev:"https://secomapp-affiliate.test",test:"https://af-test.uppromote.com",production:"https://cdn.uppromote.com"})[e]||"https://cdn.uppromote.com",this.cache=t,this.postPurchasePopup={ui:{sca_title:null}}}init(){this.dispatchLoadedEvent(),this.processOnLoadPage(),this.uppromoteLog("Running...")}assetS3(e=""){let t=this.cdnS3Host;return e.startsWith("http")?e:("production"!==this.env&&(t=`${t}/storage`),`${t}/${e=(e=e.replace("//","/")).startsWith("/")?e.slice(1,e.length):e}`)}renderElm(e="div",t,i={},o){let a=document.createElement(e);return t&&(Array.isArray(t)?t.map(e=>a.classList.add(e)):t&&0!==t.length&&a.classList.add(t)),Object.keys(i).forEach(e=>a.setAttribute(e,i[e])),o&&(a.innerHTML=o),a}async fetchAndGetContent(e="",t="GET",i={}){if(i.shopify_domain=this.getShopDomain(),["GET","HEAD"].includes(t)){e=new URL(e);let o=new URLSearchParams(i),a=e.searchParams,s=new URLSearchParams({...Object.fromEntries(o),...Object.fromEntries(a)});e=`${e.origin}${e.pathname}?${s.toString()}`;let r=await fetch(e);return await r.json()||null}{let n=new FormData;Object.keys(i).forEach(e=>n.append(e,i[e]));let c=await fetch(e,{method:t,headers:{},body:n});return await c.json()||null}}setCookie(e,t,i){let o=new Date;o.setTime(o.getTime()+864e5*i);let a="expires="+o.toUTCString();document.cookie=e+"="+t+";"+a+";path=/"}getCookie(e){let t=e+"=",i=decodeURIComponent(document.cookie).split(";");for(let o=0;o<i.length;o++){let a=i[o];for(;" "===a.charAt(0);)a=a.substring(1);if(0===a.indexOf(t))return a.substring(t.length,a.length)}return""}mustPostClickTracking(e){if(!e)return!0;let t=new Date().getTime();return t-e>6e4}checkResponseFromServer(){if("false"===localStorage.getItem("scaaf_received")){let e=this.getCookie("scaaf_aid")||localStorage.getItem("scaaf_aid");e&&this.postClickTracking({aid:e,tid:localStorage.getItem("scaaf_tid"),hc:localStorage.getItem("scaaf_hc"),s:this.getShopName(),ug:navigator.userAgent},null,()=>{uppromote.uppromoteLog("ReTracking success!")})}}parseQueryStringToObject(e=""){try{let t=new URLSearchParams(e),i=t.entries(),o={};for(let[a,s]of i)o[a]=s;return o}catch(r){return{}}}getShopDomain(){try{if(Shopify)return Shopify.shop;return""}catch(e){return console.error("Uppromote: getShopName() - Error when get shopify domain"),""}}getShopName(){return this.getShopDomain().replace(".myshopify.com","")}getShopifyCheckoutObject(){return Shopify&&Shopify.checkout?Shopify.checkout:null}getShopifyCheckoutInformationObject(){return Shopify&&Shopify.Checkout?Shopify.Checkout:null}copyToClipboard(e,t){e.focus(),e.select(),navigator.clipboard.writeText(e.value).then(t)}applyDiscountCode(e){let t=this.renderElm("iframe","sca_d-none",{src:`/discount/${e}`});t.style.display="none",document.body.append(t)}initFbPixel(){if("undefined"!=typeof disableUppromoteFacebookPixel)return;let e=this.renderElm("script","sca_aff_fb_pixel_init");e.textContent='!function(a,c,b,d,e,f,g){a.fbq||(e=a.fbq=function(){e.callMethod?e.callMethod.apply(e,arguments):e.queue.push(arguments)},!a._fbq&&(a._fbq=e),e.push=e,e.loaded=!0,e.version="2.0",e.queue=[],f=c.createElement(b),f.async=!0,f.src=d,g=c.getElementsByTagName(b)[0],g.parentNode.insertBefore(f,g))}(window,document,"script","https://connect.facebook.net/en_US/fbevents.js");',document.head.append(e)}getCouponCode(e,t){let i=`${this.host}/api/get_coupon`,o=e||this.getCookie("scaaf_aid");o&&this.fetchAndGetContent(i,"GET",{aid:o}).then(e=>{"ok"===e.status?(uppromote.applyDiscountCode(e.coupon),setTimeout(()=>{t&&(window.location.href=`${t}&discount=${e.coupon}`)},200)):t&&(window.location.href=t)}).catch(()=>{t&&(window.location.href=t)})}trackFbPixel(e){if("undefined"!=typeof disableUppromoteFacebookPixel)return;let t=`${this.host}/api/get_fb_pixel`,i={aff_id:e||this.getCookie("scaaf_aid")||localStorage.getItem("scaaf_aid"),shop:`${this.getShopDomain()}`},o=function(e){let t=uppromote.getShopifyCheckoutObject(),i=uppromote.getShopifyCheckoutInformationObject();fbq("init",e),fbq("trackSingle",e,"PageView"),t&&fbq("trackSingle",e,"Purchase",{value:t.total_price,currency:t.currency}),i&&"contact_information"===i.step&&fbq("trackSingle",e,"InitiateCheckout",{currency:t.currency,value:t.estimatedPrice}),document.location.pathname.startsWith("/cart")&&fbq("trackSingle",e,"AddToCart")};i.aff_id&&this.fetchAndGetContent(t,"GET",i).then(e=>{"ok"===e.status&&o(e.pixel)}).catch(e=>{console.error("Uppromote: trackFbPixel() - Error when fetch Fb pixel"),console.error(e)})}appendAffiliateIdToRegisterForm(e=null){if(!this.getCookie("scaaf_ass_dl"))return;let t=window.location.pathname.split("/")[2]||"";if("register"!==t||!(e=e||this.getCookie("scaaf_aid")||localStorage.getItem("scaaf_aid")))return;let i=document.querySelector('form[method="post"][action*="account"]');if(!i)return;let o=this.renderElm("input",null,{type:"hidden",name:"customer[note][affiliate_id]",value:e});i.append(o)}getPostPurchasePopupSetting(){let e=`${this.host}/api/purchase_popup/setting`,t=this.getShopifyCheckoutObject();if(!t||!t.email)return;let i={email:t.email,shop:this.getShopDomain()};this.fetchAndGetContent(e,"GET",i).then(e=>{"ok"===e.status&&uppromote.renderPostPurchasePopup(e)})}renderPostPurchasePopup(e){if(this.getCookie("sca_p_p_show_once")&&1===e.settings.show_only_once)return;1===e.settings.show_only_once&&this.setCookie("sca_p_p_show_once",1,360);let t=e.settings,i=e.nonActiveAffiliate,o=t.design,a=t.promotion_method,s=t.custom_css,r=e.customize,n=`${this.cdnHost}/css/script_tag/script_affiliate.css`,c=this.renderElm("link",null,{href:`${n}${this.cache?"":`?v=${new Date().getTime()}`}`,rel:"stylesheet"}),l=this.renderElm("style",null,{},s);document.head.append(c,l);let p=this.renderElm("div","sca_purchase_popup_modal_container"),d=this.renderElm("div",["sml","is-open"],{id:"modal-1","aria-hidden":"false"}),u=this.renderElm("div","sca_modal_overlay",{id:"sca_modal_overlay",tabindex:"-1","data-micromodal-close":""}),h=this.renderElm("div","sca_modal_container",{id:"modal_container",role:"dialog","aria-modal":"true","aria-labelledby":"modal-1-title"}),m=this.renderElm("button",["sca_modal_close","x-btn"],{"aria-label":"Close modal","data-micromodal-close":"",id:"sca_post_purchase_popup_close_button"},"x"),f=this.renderElm("div",null,{id:"sca_popup"}),g=this.renderElm("div","sca_modal_image",{alt:"Post purchase popup"}),k="none"===o.header_image?this.cdnHost+"/img/default_popup.jpg":this.assetS3(o.header_image);"/img/default_popup.jpg"===o.header_image&&(k=this.cdnHost+"/img/default_popup.jpg"),g.style.backgroundImage=`url(${k})`,g.style.height=`${o.image_height}px`;let b=this.renderElm("div",null,{id:"sca_main"}),C=this.renderElm("div",null,{id:"sca_content"}),y=this.renderElm("div",null,{id:"sca_title"},o.title);y.style.color=o.title_color;let v=this.renderElm("div",null,{id:"sca_subtitle"},2===a?o.sub_title_coupon:o.sub_title);this.postPurchasePopup.ui.sca_title=v;let E,w;if(r){E=this.renderElm("div","scaaff_require_term"),w=this.renderElm("input",null,{type:"checkbox",id:"confirm-term",name:"confirm-term"});let T=this.renderElm("label",null,{for:"confirm-term"},`I agree with <a href='${r.term}' target='_blank'>Terms and Conditions</a>`);E.append(w,T)}let I=this.renderElm("div","sca_result_wrapper",{id:"sca_result_wrapper"}),S="Active my account";(void 0!==o.button_text_non_auto_active||null!=o.button_text_non_auto_active)&&(S=o.button_text_non_auto_active);let P=i?S:2===a?o.button_text_coupon:o.button_text,$=this.renderElm("button",null,{id:"sca_reg_mode_manual_btn","data-origin-text":P},P);$.style.cursor=r?"not-allowed":"pointer",$.style.backgroundColor=o.button_background,$.style.color=o.button_text_color,$.style.borderRadius=`${o.button_border_radius}px`;let A=this.renderElm("div","sca_share_container",{id:"sca_share"}),x=function(){d.setAttribute("aria-hidden","true"),setTimeout(()=>{p.style.display="none"},300)},_=function(){r&&($.style.cursor=w.checked?"pointer":"not-allowed",$.disabled=!w.checked)},L=function(){if(r){w.checked&&uppromote.postRegisterAffiliatePostPurchasePopup();return}uppromote.postRegisterAffiliatePostPurchasePopup()};$.append(A),I.append($),C.append(y,v),E&&C.append(E),C.append(I),b.append(C),f.append(g,b,A),h.append(m,f),u.append(h),d.append(u),p.append(d),document.body.append(p),m.addEventListener("click",x),1===t.close_background_click&&document.addEventListener("click",function(e){e.target===u&&x()}),E&&w&&w.addEventListener("change",_),$.addEventListener("click",L)}postRegisterAffiliatePostPurchasePopup(){let e=document.getElementById("sca_reg_mode_manual_btn"),t=document.getElementById("sca_result_wrapper");if(!e&&!t)return;let i=function(t=!0){e.disabled=t,e.style.cursor=t?"not-allowed":"pointer",e.textContent=t?"Loading...":e.dataset.originText},o=this.getShopifyCheckoutObject();if(!o||!o.email)return;let a=function(e){let i=uppromote.renderElm("div","result_wrapper"),o=uppromote.renderElm("div","input-link-wrapper"),a=uppromote.renderElm("input","sca_ip",{id:"sca_referral_link_ip",type:"text",value:e.coupon_code||e.referral_link}),s=e.coupon_code?"Copy coupon":"Copy link",r=uppromote.renderElm("button",["sca_bt","sca_btn_copy"],{id:"sca_popup_copy_btn"},s);if(e.nonActiveAffiliate){(()=>{if(1===e.promotion_method){let o=uppromote.renderElm("div",null,{id:"sca_div_link"},"Thanks for joining our Affiliate program. An email containing Affiliate link will be sent to you once your account is reviewed.");i.append(o)}else{let a=uppromote.renderElm("div",null,{id:"sca_div_coupon"},"Thanks for joining our Affiliate program. An email containing Affiliate coupon will be sent to you once your account is reviewed.");i.append(a)}t.innerHTML="",t.append(i),uppromote.postPurchasePopup.ui.sca_title&&uppromote.postPurchasePopup.ui.sca_title.remove()})();return}o.append(a),i.append(o,r),t.innerHTML="",t.append(i),r.addEventListener("click",()=>{uppromote.copyToClipboard(a,()=>{r.textContent="Copied!",setTimeout(()=>{r.textContent=s},1e3)})});let n={facebook:{title:"Share on Facebook",img:`${uppromote.cdnHost}/img/facebook.svg`,shareUrl:"https://www.facebook.com/sharer.php?u="},twitter:{title:"Share on Twitter",img:`${uppromote.cdnHost}/img/twitter.svg`,shareUrl:"https://twitter.com/intent/tweet?url="},pinterest:{title:"Share on Pinterest",img:`${uppromote.cdnHost}/img/pinterest.svg`,shareUrl:"https://pinterest.com/pin/create/link/?url="},linkedin:{title:"Share on LinkedIn",img:`${uppromote.cdnHost}/img/linkedin.svg`,shareUrl:"https://www.linkedin.com/shareArticle?mini=true&url="}},c=document.getElementById("sca_share");for(let l in n){let p=uppromote.renderElm("a",null,{target:"_blank",title:n[l].title,href:`${n[l].shareUrl}${e.referral_link}`}),d=uppromote.renderElm("img",null,{alt:n[l].title,src:n[l].img});p.append(d),c.append(p)}c.style.display="block"},s=function(e){let t=e.message,o=document.querySelector("#sca_popup #sca_content"),a=o.querySelector("#sca_subtitle"),s=o.querySelector("#sca_post_purchase_error");s&&s.remove(),s=uppromote.renderElm("p","sca_post_purchase_error",{id:"sca_post_purchase_error"},t),t&&o&&a.after(s),i(!1)},r={email:o.email,first_name:o.billing_address.first_name,last_name:o.billing_address.last_name,shop:this.getShopDomain()},n=this.getCookie("scaaf_aid")||localStorage.getItem("scaaf_aid"),c=o.discount?o.discount.code:null;n&&(r.affiliate_id=n),c&&(r.coupon=c),i(),this.fetchAndGetContent(`${this.host}/api/post_affiliate_purchase`,"POST",r).then(e=>{"ok"===e.status?a(e):s(e)})}postClickTracking(e,t,i){localStorage.getItem("scaaf_sca_source_secomus")&&(e.sca_source=localStorage.getItem("scaaf_sca_source_secomus")),this.fetchAndGetContent(`${this.host}/api/click_tracking`,"POST",e).then(o=>{if("ok"===o.status){this.uppromoteLog(`Tracking affiliate id ${e.aid}`),this.setLocalTrackingReceivedVariables(o),this.getCouponCode(),this.dispatchTrackingAffiliateEvent(!0,o),i&&i(o),this.runCustomizePostClickTrackingCallback(o);return}t&&clearInterval(t),this.dispatchTrackingAffiliateEvent(!1,o),i&&i(o)}).catch(e=>{t&&clearInterval(t),this.dispatchTrackingAffiliateEvent(!1,response),i&&i(e),console.warn(e)})}dispatchLoadedEvent(){let e=new CustomEvent("uppromote:loaded"),t=()=>window.dispatchEvent(e);this.waitCustomerReferralExtension(t),this.waitMessageBarExtension(t)}dispatchTrackingAffiliateEvent(e=!1,t={}){let i=new CustomEvent("uppromote:tracked-affiliate",{detail:{available:e,info:t}}),o=()=>window.dispatchEvent(i);this.waitCustomerReferralExtension(o),this.waitMessageBarExtension(o)}waitCustomerReferralExtension(e,t){let i=setInterval(()=>{"undefined"!=typeof UppromoteCustomerReferral&&(clearInterval(i),e())},500);setTimeout(()=>{clearInterval(i),t&&t()},1e4)}waitMessageBarExtension(e,t){let i=setInterval(()=>{"undefined"!=typeof UppromoteMessageBar&&(clearInterval(i),e())},500);setTimeout(()=>{clearInterval(i),t&&t()},1e4)}postCheckoutToken(){let e=this.getShopifyCheckoutObject(),t=this.getShopifyCheckoutInformationObject();if(t&&t.token&&e&&null!=localStorage.getItem("scaaf_aid")&&localStorage.getItem("scaaf_ep")>new Date().getTime()){let i={aid:localStorage.getItem("scaaf_aid"),ct_tk:t.token,s:this.getShopName(),hc:localStorage.getItem("scaaf_hc"),order_id:e.order_id};localStorage.getItem("scaaf_sca_source_secomus")&&(i.sca_source=localStorage.getItem("scaaf_sca_source_secomus")),this.fetchAndGetContent(`${this.host}/api/ct_tk`,"POST",i).then(()=>{}).catch(e=>{console.error(e)})}}postCartToken(e,t){e.ug=navigator.userAgent,localStorage.getItem("scaaf_sca_source_secomus")&&(e.sca_source=localStorage.getItem("scaaf_sca_source_secomus")),this.fetchAndGetContent(`${this.host}/api/ctk`,"POST",e).then(i=>{"ok"===i.status&&(this.setCookie("scaaf_tid",i.tid,360),localStorage.setItem("scaaf_tid",i.tid),localStorage.setItem("scaaf_ctk",e.ctk),this.setCookie("scaaf_ctk",e.ctk,360),localStorage.setItem("scaaf_received","true")),clearInterval(t)}).catch(e=>{clearInterval(t),console.error(e)})}processOnLoadPage(){let e=this.parseQueryStringToObject(window.location.search.substring(1));if(e.sca_ref){let t=e.sca_ref.split("."),i={aid:t[0],hc:t[1],s:this.getShopName(),tid:localStorage.getItem("scaaf_tid"),ug:navigator.userAgent},o=localStorage.getItem("scaaf_c_c"),a=new Date().getTime(),s=this.mustPostClickTracking(o);s&&(this.setLocalTrackingVariables(i.aid,!1,i.hc,a,e.sca_source),this.postClickTracking(i,null)),e.sca_rib&&(this.getCookie("scaaf_aid")?this.getCouponCode(i.aid,e.sca_rib):window.location.href=e.sca_rib)}else this.checkResponseFromServer(),this.getCouponCode();this.intervalCheckCartToken(),this.postCheckoutToken(),this.appendAffiliateIdToRegisterForm(),this.getPostPurchasePopupSetting(),this.initFbPixel(),setTimeout(()=>uppromote.trackFbPixel(),200)}setLocalTrackingVariables(e,t=!1,i,o,a){localStorage.setItem("scaaf_aid",e),localStorage.setItem("scaaf_received",t?"true":"false"),localStorage.setItem("scaaf_hc",i),localStorage.setItem("scaaf_c_c",o),this.setCookie("scaaf_aid",e,360),this.setCookie("scaaf_c_c",o,360),a&&(localStorage.setItem("scaaf_sca_source_secomus",a||""),this.setCookie("scaaf_sca_source_secomus",a||"",360))}setLocalTrackingReceivedVariables(e={}){localStorage.setItem("scaaf_received","true"),localStorage.setItem("scaaf_tid",e.tid),localStorage.setItem("scaaf_ep",(1e3*e.ep).toString()),this.setCookie("scaaf_tid",e.tid,360),this.setCookie("scaaf_ep",1e3*e.ep,360),this.setCookie("scaaf_afn",e.afd.affiliate_name||"",e.afcookie),this.setCookie("scaaf_afc",e.afd.company||"",e.afcookie),this.setCookie("scaaf_affn",e.afd.affiliate_firstname||"",e.afcookie),this.setCookie("scaaf_pd",e.afd.personal_detail||"",e.afcookie),e.enable_assign_down_line&&this.setCookie("scaaf_ass_dl",1,e.afcookie)}intervalCheckCartToken(){let e=()=>{let e=localStorage.getItem("scaaf_ctk"),i=this.getCookie("cart");if(!i)return;let o=localStorage.getItem("scaaf_tid"),a=localStorage.getItem("scaaf_aid");if(o&&a){let s=localStorage.getItem("scaaf_ep");if(s&&s<new Date().getTime()){clearInterval(t);return}if(e!==i){let r=this.getShopifyCheckoutObject();if(r){clearInterval(t);return}this.postCartToken({aid:localStorage.getItem("scaaf_aid"),tid:localStorage.getItem("scaaf_tid"),ctk:i,s:this.getShopName()},t)}}"false"===localStorage.getItem("scaaf_received")&&this.postClickTracking({aid:localStorage.getItem("scaaf_aid"),tid:localStorage.getItem("scaaf_tid"),hc:localStorage.getItem("scaaf_hc"),s:this.getShopName(),ug:navigator.userAgent},t)},t=setInterval(e,1e3)}runCustomizePostClickTrackingCallback(e){if("function"==typeof scaAffClickTrackingCallback)try{scaAffClickTrackingCallback(e)}catch(t){console.log(t)}}uppromoteLog(e){console.log(`%c â–º UpPromote Affiliate Marketing [Application] - ${e}`,"background-color: #092C4C; color: #fff; padding: 5px;")}}const uppromote=new Uppromote("production");uppromote.init();