1document.addEventListener('DOMContentLoaded',function(){const COOKIE_NAME='geo_country_v2';function readCookie(name){const m=document.cookie.match(new RegExp('(?:^|;\\s*)'+name+'=([^;]*)'));return m?decodeURIComponent(m[1]):''} 2function parseGeoCookie(raw){if(!raw)return null;const parts=raw.split('.');if(parts.length!==3)return null;const iso=(parts[0]||'').toUpperCase();const exp=parseInt(parts[1],10);const sig=parts[2]||'';if(!/^[A-Z]{2}$/.test(iso)||!Number.isFinite(exp)||!sig)return null;return{iso,exp,sig}} 3function isCookieFresh(c){if(!c)return!1;const now=(EWR_DATA&&EWR_DATA.now)?EWR_DATA.now:Math.floor(Date.now()/1000);return c.exp>now} 4function fetchReplacements(){return fetch('/wp-json/english-word-replacer/v1/replacements',{cache:'no-store'}).then(r=>r.json()).catch(()=>[])} 5function replaceWords(replacements){const map={};const british=[];replacements.forEach(pair=>{const b=pair.british_word;const a=pair.american_word;if(!b||!a)return;map[b.toLowerCase()]=a;british.push(escapeRegExp(b))});if(british.length===0)return;const pattern=new RegExp('\\b('+british.join('|')+')\\b','gi');function transformCase(orig,repl){if(orig===orig.toUpperCase())return repl.toUpperCase();if(orig[0]===orig[0].toUpperCase())return repl[0].toUpperCase()+repl.slice(1);return repl.toLowerCase()} 6function walk(node){if(node.nodeType===Node.ELEMENT_NODE&&(node.nodeName==='SCRIPT'||node.nodeName==='STYLE'))return;if(node.nodeType===Node.TEXT_NODE){const text=node.nodeValue;const out=text.replace(pattern,(m)=>{const k=m.toLowerCase();const a=map[k];return a?transformCase(m,a):m});if(out!==text)node.nodeValue=out}else{node.childNodes.forEach(walk)}} 7walk(document.body)} 8function escapeRegExp(s){return s.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')} 9function ensureCountryISO(){const raw=readCookie(COOKIE_NAME);const parsed=parseGeoCookie(raw);if(parsed&&isCookieFresh(parsed)){return Promise.resolve(parsed.iso)} 10const url=(EWR_DATA&&EWR_DATA.ajax_url)?EWR_DATA.ajax_url:'/wp-admin/admin-ajax.php';const qs=(url.indexOf('?')===-1?'?':'&')+'action=ewr_bootstrap_geo&_='+Date.now();return fetch(url+qs,{method:'GET',cache:'no-store',credentials:'same-origin'}).then(r=>r.json()).then(json=>{if(json&&json.success&&json.data&&json.data.country_code){return json.data.country_code.toUpperCase()} 11return''}).catch(()=>'')} 12ensureCountryISO().then((iso)=>{if(iso==='US'){fetchReplacements().then((repl)=>{if(Array.isArray(repl)&&repl.length){replaceWords(repl)}})}})})
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.