(function(){"use strict";console.log("[TrendsExtension] content script active on",location.href),(function(){const e=document.createElement("script");e.src=chrome.runtime.getURL("trends-sniffer.js"),e.onload=()=>{e.remove()},(document.head||document.documentElement).appendChild(e)})();const c="https://trends.google.com/trends/api/widgetdata/",o="https://trends.google.com",d=["relatedsearches","multiline"],s=12e4;function u(t){return typeof t=="object"&&t!==null}function i(t){try{return new URL(t,location.origin).href}catch{return t}}function l(t){const e=i(t);return e.startsWith(o)&&d.some(n=>e.startsWith(c+n))}function a(t){const e=typeof t=="string"?t:"";return e.length>s?e.slice(0,s):e}window.addEventListener("message",t=>{if(t.source!==window||t.origin!==o)return;const e=t.data;if(!(e!=null&&e.__trendsSniffer)||e.type!=="trends-relatedsearches"&&e.type!=="trends-multiline"&&e.type!=="trends-lifecycle")return;if(e.type==="trends-lifecycle"){if(!u(e.payload))return;chrome.runtime.sendMessage({type:e.type,payload:e.payload});return}if(e.kind!=="xhr"&&e.kind!=="fetch")return;const n=typeof e.url=="string"?i(e.url):"";if(!n||!l(n))return;const r=Number(e.status??0);!Number.isFinite(r)||r<0||r>999||chrome.runtime.sendMessage({type:e.type,payload:{url:n,status:r,body:a(e.body)}})})})();
