1const dateTime = new Date(); 2const dateHour = dateTime.getDate().toString().padStart(2, 0) + 3 dateTime.getHours().toString().padStart(2, 0); 4 5const fixLinks = (e = null) => { 6 if (e) e.preventDefault(); 7 8 const affiliateLinks = Array 9 .from(document.querySelectorAll('article a[href*=amazon], article a[href*=amzn]')) 10 .map(el => { 11 const url = new URL(el.getAttribute('href')); 12 const searchParams = new URLSearchParams(url.search); 13 let subtag = searchParams.get('ascsubtag'); 14 15 if (!subtag) { 16 return false; 17 } 18 19 subtag = encodeURI(subtag); 20 21 return { el, subtag, decodedSubtag: decodeURI(subtag) }; 22 }) 23 .filter(link => !!link); 24 25 if (affiliateLinks.length < 1) return; 26 27 let { innerWidth: width, innerHeight: height } = window; 28 29 width = width 30 .toString() 31 .substring(0, 4) 32 .padStart(4, 0); 33 34 height = height 35 .toString() 36 .substring(0, 4) 37 .padStart(4, 0); 38 39 affiliateLinks.map(link => { 40 const newSubtag = encodeURI( 41 link.decodedSubtag.substring(0, 17) + 42 width + 43 height + 44 link.decodedSubtag.substring(25, 35) + 45 dateHour + 46 link.decodedSubtag.substring(39, 100) 47 ); 48 49 link.el.setAttribute( 50 'href', 51 link.el.getAttribute('href').replace(link.subtag, newSubtag) 52 ); 53 54 console.info('Subtag replaced from\n', link.subtag, '\nto', newSubtag); 55 }) 56}; 57 58window.addEventListener('resize', e => fixLinks(e)); 59 60fixLinks();
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.