1//Make an interval that runs every 100 milliseconds to look for the link 2//define the elements on the parent page that we need 3 let amb_data1 = JSON.parse(localStorage.getItem('mbsy/cookie')); 4 let params1 = new URLSearchParams(window.location.search); 5 let amb_short_code1; 6 let amb_campaign_id1; 7 let amb_source1; 8 let amb_exp1; 9 if (amb_data1) { 10 amb_short_code1 = amb_data1['value']['mbsy_cookie_code']; 11 amb_campaign_id1 = amb_data1['value']['mbsy_cookie_campaign']; 12 amb_source1 = amb_data1['value']['mbsy_source']; 13 amb_exp1 = amb_data1['mbsyExpiration']; 14 }; 15 if (!amb_campaign_id1 && params1.has('campaignid')) { 16 amb_campaign_id1 = params1.get('campaignid'); 17 }; 18 if (!amb_short_code1 && params1.has('mbsy')) { 19 amb_short_code1 = params1.get('mbsy'); 20 }; 21 if (!amb_source1 && params1.has('mbsy_source')) { 22 amb_source1 = params1.get('mbsy_source'); 23 }; 24 if (!amb_exp1 && params1.has('mbsy_exp')) { 25 amb_exp1 = params1.get('mbsy_exp'); 26 }; 27 //if the link has loaded on the page, try to update it 28 let links = []; 29 let targetUrl = ''; 30 let updated = 0; 31 // Delay everything by 3 seconds (3000 milliseconds) 32 setTimeout(() => { 33 const linkInterval = setInterval(() => { 34 links = Array.from(document.querySelectorAll('a')); 35 if (links.length > 0 && amb_short_code1 && amb_campaign_id1) { 36 let new_params = new URLSearchParams(); 37 new_params.append('campaignid', amb_campaign_id1); 38 new_params.append('mbsy', amb_short_code1); 39 new_params.append('mbsy_source', amb_source1); 40 new_params.append('mbsy_exp', amb_exp1); 41 console.log('Ambassador: created new search params'); 42 links.forEach((link, i) => { 43 if (link.href.includes(targetUrl) && link.href.includes('?')) { 44 link.href = link.href + '&' + new_params.toString(); 45 updated = updated + 1; 46 console.log('Ambassador: button has been updated', i); 47 } else if (link.href.includes(targetUrl)) { 48 link.href = link.href + '?' + new_params.toString(); 49 updated = updated + 1; 50 console.log('Ambassador: link has been updated', i); 51 }; 52 }); 53 console.log(updated, '<--- Ambassador updated links'); 54 if (updated > 1) { 55 clearInterval(linkInterval); 56 }; 57 }; 58 }, 100); 59 }, 3000);
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.