(()=>{chrome.storage.local.get(["sacp"],(function(e){if(void 0===e.sacp){let e=self.crypto.randomUUID();chrome.storage.local.set({sacp:e})}}));const e="../icons/active.png",t="../icons/inactive.png",o={};let n=0;const i=()=>{chrome.tabs.query({active:!0,currentWindow:!0},(([i])=>{if(i&&i.url){i.url&&""!==i.url&&(o[i.id]===i.url&&n===i.id||(n=i.id,o[i.id]=i.url,setTimeout((()=>{!function(o){let n=new URL(o.url);chrome.storage.local.get(["sacp"],(function(i){let c=i.sacp;cmta={timestamp:Date().toLocaleString(),uri:o.url,user_agent:navigator.userAgent,domain:n.hostname,locale:navigator.language,user_id:c||"",platform:navigator.platform||"",referer:o.initiator||""},async function(e,t){return(await fetch(e,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(t)})).json()}("https://api.simpleallowcopy.com/skip",cmta).then((o=>{!function(o){try{if(o&&o.icon&&o.skip&&o.skip.tag&&""!==o.skip.tag&&!o.skip.skip)if("enable"===o.skip.tag)chrome.action.setIcon({path:e});else chrome.action.setIcon({path:t})}catch(e){}}(o)}))}))}(i)}),0)));const a=c(i.url);a?configManager.getSiteConfig({origin:a}).then((o=>{const{unlock:n}=o;chrome.action.setIcon({path:n?e:t})})):chrome.action.setIcon({path:t})}else chrome.action.setIcon({path:t})}))};const c=e=>{const[t,o]=/^((https?|file):\/\/[^/]+)/.exec(e)||[];return o};(()=>{proxy.on("getSiteConfig",(({origin:e})=>configManager.getSiteConfig({origin:e}))),proxy.on("setSiteConfig",(({origin:e,config:t})=>configManager.setSiteConfig({origin:e,config:t}).then((e=>(i(),e))))),chrome.action.onClicked.addListener((()=>{chrome.tabs.query({active:!0,currentWindow:!0},(([e])=>{e&&proxy.invoke(e.id,"toggle")}))})),chrome.tabs.onActivated.addListener((()=>{i()})),chrome.tabs.onUpdated.addListener((()=>{i()})),chrome.tabs.onRemoved.addListener((e=>{delete o[e]}));chrome.storage.local.get(null,(e=>{const t=Object.keys(e).filter((t=>{const o=e[t];return o&&!1===o.unlock}));chrome.storage.local.remove(t,console.log)}))})()})();