1jQuery(function ($) { 2 const $selector = $('a.mobile_app_link, a[href^="https://amarkets.onelink.me/"]'); 3 4 setTimeout(set_link, 5000); 5 6 function set_link() { 7 const promo_code_local = get_promo_code_internal() || get_promo_code_url() || get_cookie('promo_code'); 8 9 if (promo_code_local) { 10 // ÐолÑÑиÑÑ Ð»Ð¾ÐºÐ°Ð»ÑнÑй promo_code 11 set_promo_code_to_link(promo_code_local); 12 set_utm_to_link(); 13 } else { 14 // ÐолÑÑиÑÑ ÐºÑоÑÑдоменнÑй promo_code 15 // ÐлобалÑÐ½Ð°Ñ Ñ-Ñ Ð¾Ð±ÑÑÐ²Ð»ÐµÐ½Ð½Ð°Ñ Ð² /amarkets-common/js/ampc/ampc-client.js 16 get_promo_code(function (promo_code_crossdomain) { 17 if (promo_code_crossdomain) { 18 set_promo_code_to_link(promo_code_crossdomain); 19 set_utm_to_link(); 20 } else { 21 set_utm_to_link(); 22 } 23 24 return; 25 }); 26 } 27 } 28 29 function set_utm_to_link() { 30 const utm = get_utm_url() || get_utm_cookie(); 31 32 if (utm) { 33 const utm_string = `&af_sub1=${utm.utm_source}&af_sub2=${utm.utm_medium}&af_sub3=${utm.utm_campaign}&af_sub4=${utm.utm_content}&af_sub5=${utm.utm_term}`; 34 35 $selector.each(function (idx, link) { 36 link.href += utm_string; 37 }); 38 } 39 } 40 41 function get_utm_url() { 42 const url = window.location.search; 43 const search_params = new URLSearchParams(url); 44 let utm_params = null; 45 46 if (search_params.has('utm_source') || search_params.has('utm_medium') || search_params.has('utm_campaign') || search_params.has('utm_c
46ontent') || search_params.has('utm_term')) { 47 utm_params = { 48 'utm_source': search_params.get('utm_source') || 'direct', 49 'utm_medium': search_params.get('utm_medium') || 'none', 50 'utm_campaign': search_params.get('utm_campaign') || 'direct', 51 'utm_content': search_params.get('utm_content') || 'none', 52 'utm_term': search_params.get('utm_term') || 'none', 53 } 54 } 55 56 return utm_params; 57 } 58 59 function get_utm_cookie() { 60 let utmz_string = get_cookie('__utmz'); 61 62 const utm = (function () { 63 let ga = {}; 64 65 if (utmz_string) { 66 utmz_string = utmz_string.replace(/[{()}]/g, ''); 67 const pairs = utmz_string.split('.').slice(4).join('.').split('|'); 68 69 for (let i = 0; i < pairs.length; i++) { 70 let temp = pairs[i].split('='); 71 ga[temp[0]] = temp[1]; 72 } 73 } 74 75 return ga; 76 })(); 77 const { utmccn, utmcct, utmcmd, utmcsr, utmctr } = utm; 78 79 return utmz_string ? { 80 'utm_source': utmcsr || 'direct', 81 'utm_medium': utmcmd || 'none', 82 'utm_campaign': utmccn || 'direct', 83 'utm_content': utmcct || 'none', 84 'utm_term': utmctr || 'none', 85 } : null; 86 } 87 88 function set_promo_code_to_link(promo_code) { 89 const link = { 90 start: 'https://amarkets.onelink.me/E2NR?af_xp=mobile_app&pid=source', 91 end: '&af_dp=com.amarkets%3A%2F%2F', 92 } 93 const link_promo_code = link.start + '&deep_link_value=g_' + promo_code + '&deep_link_sub1=g_' + promo_code + link.end; 94 95 if (window.mobile_app && window.mobile_app.new_link) { 96 // еÑли Ð´Ð»Ñ ÑÑÑаниÑÑ Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ задаÑÑ Ð´ÑÑгÑÑ onelink ÑÑÑлкÑ, пеÑедаем пÑомокод в Ð½ÐµÑ 97 $selector.attr('href', window.mobile_app.new_link + '?g=' + promo_code); 98 } else { 99 $selector.attr('href', link_promo_code); 100 } 101 } 102 103 function get_promo_code_internal() { 104 return window.mobile_app_popup_promo_code; 105 } 106 107 function get_promo_code_url() { 108 const window_location = window.location; 109 const url_params = window_location.search.includes('g=') ? window_location.search : window_location.hash.replace('#', ''); 110 const querystring = new URLSearchParams(url_params); 111 const promo_code = querystring.get('g'); 112 113 return promo_code; 114 } 115 116 function get_cookie(name) { 117 const matches = document.cookie.match(new RegExp( 118 '(?:^|; )' + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + '=([^;]*)' 119 )); 120 121 return matches ? decodeURIComponent(matches[1]) : undefined; 122 } 123});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.