1(function () { 2 if (typeof advanced_ads_pro === 'undefined') { 3 return; 4 } 5 6 advanced_ads_pro.observers.add(function (event) { 7 if ( 8 [ 9 'inject_passive_ads', 10 'inject_ajax_ads', 11 'advanced_ads_decode_inserted_ads', 12 'inject_placement', 13 ].indexOf(event.event) === -1 14 ) { 15 return; 16 } 17 18 if (Array.isArray(event.ad_ids) && !event.ad_ids.length) { 19 event.ad_ids = {}; 20 } 21 22 var server = 'all', 23 adIds = {}; 24 25 // find targets for click tracking. 26 if (document.readyState !== 'complete') { 27 document.addEventListener('readystatechange', function (e) { 28 if (e.target.readyState === 'complete') { 29 window.AdvAdsClickTracker.findTargets(); 30 } 31 }); 32 } else { 33 window.AdvAdsClickTracker.findTargets(); 34 } 35 36 switch (event.event) { 37 // waiting for the moment when all passive cache-busting ads will be inserted into html 38 case 'inject_passive_ads': 39 window.AdvAdsImpressionTracker.passiveAds = 40 AdvAdsTrackingUtils.concat( 41 window.AdvAdsImpressionTracker.passiveAds, 42 event.ad_ids 43 ); 44 45 for (var bid in event.ad_ids) { 46 if (advads_tracking_methods[bid] === 'frontend') { 47 // cache-busting: off + cache-busting: passive 48 adIds = AdvAdsTrackingUtils.concat( 49 advads_tracking_ads, 50 event.ad_ids 51 ); 52 53 // clean cache-busting: off 54 advads_tracking_ads = { 1: [] }; 55 } else { 56 // select only passive cache-busting ads 57 server = 'passive'; 58 adIds = event.ad_ids; 59 } 60 61 // remove ads that have not been decoded. 62 if ( 63 typeof advads !== 'undefined' && 64 typeof advads.privacy.is_ad_decoded !== 'undefined' 65 ) { 66 for (var bid in adIds) { 67 adIds[bid] = adIds[bid].filter( 68 advads.privacy.is_ad_decoded 69 ); 70 } 71 } 72 } 73 break; 74 case 'inject_ajax_ads': 75 var is_tcf = 76 typeof advads !== 'undefined' && 77 window.advads_options.privacy['enabled'] && 78 window.advads_options.privacy['consent-method'] === 79 'iab_tcf_20'; 80 81 for (var bid in event.ad_ids) { 82 if (!AdvAdsTrackingUtils.blogUseGA(bid) && !is_tcf) { 83 continue; 84 } 85 86 for (var i in event.ad_ids[bid]) { 87 var el = document.querySelector( 88 '[data-' + 89 AdvAdsTrackingUtils.getPrefixedAttribute( 90 'trackid' 91 ) + 92 '="' + 93 event.ad_ids[bid][i] + 94 '"][data-' + 95 AdvAdsTrackingUtils.getPrefixedAttribute( 96 'trackbid' 97 ) + 98 '="' + 99 bid + 100 '"]' 101 ); 102 103 // this is a trigger-able ad. will be tracked on display if using frontend or ga method. 104 if ( 105 el !== null && 106 typeof advads_items !== 'undefined' && 107 typeof advads_items.showed !== 'undefined' && 108 advads_items.showed.indexOf(el.id) > -1 && 109 typeof el.dataset.delayed !== 'undefined' 110 ) { 111 continue; 112 } 113 114 if ( 115 typeof window.AdvAdsImpressionTracker.ajaxAds[ 116 bid 117 ] === 'undefined' 118 ) { 119 window.AdvAdsImpressionTracker.ajaxAds[bid] = []; 120 } 121 window.AdvAdsImpressionTracker.ajaxAds[bid].push( 122 event.ad_ids[bid][i] 123 ); 124 } 125 } 126 127 // If the privacy setting is TCF and we're using frontend tracking, track all IDs via JS. 128 server = 129 is_tcf && advads_tracking_methods[bid] === 'frontend' 130 ? 'all' 131 : 'ajax'; 132 adIds = JSON.parse( 133 JSON.stringify(window.AdvAdsImpressionTracker.ajaxAds) 134 ); 135 break; 136 case 'advanced_ads_decode_inserted_ads': 137 adIds = event.ad_ids; 138 break; 139 } 140 141 // wait for pro to become idle, to make sure we have all ads correctly injected. 142 if (advanced_ads_pro.busy) { 143 document.addEventListener( 144 'advanced_ads_pro.idle', 145 function () { 146 window.AdvAdsImpressionTracker.track( 147 window.AdvAdsImpressionTracker.removeDelayedAds(adIds), 148 server 149 ); 150 }, 151 { once: true } 152 ); 153 } else { 154 window.AdvAdsImpressionTracker.track( 155 window.AdvAdsImpressionTracker.removeDelayedAds(adIds), 156 server 157 ); 158 } 159 }); 160})();
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.