"use strict";chrome.runtime.onMessage.addListener(((e,n,t)=>{if("contentScriptIsInjected"===e.action)return t(!0),!0})),async function(){window.addEventListener("message",(e=>{var n;if(null===(n=e.data)||void 0===n||!n.action)return;const{action:t,msgId:s,msgData:o}=e.data,a=n=>{e.source.postMessage({action:"dt-plugin-extensionResponse",msgId:s,msgData:n},{targetOrigin:e.origin})};switch(t){case"getExtensionId":chrome.runtime.sendMessage({action:"getExtensionId"},(e=>{e&&e.extensionId?(window.postMessage({action:"sendExtensionId",extensionId:e.extensionId},"*"),a(e.extensionId)):console.error("Failed to get extension ID")}));break;case"setI18n":const n=e.data.uiLanguage;chrome.runtime.sendMessage(e.data.extensionId,{uiLanguage:n,action:"setI18n"},(e=>{chrome.runtime.lastError?window.postMessage({action:"setI18nCallBack",error:chrome.runtime.lastError.message},"*"):e?window.postMessage({action:"setI18nCallBack",callBack:!0},"*"):e&&e.error?window.postMessage({action:"setI18nCallBack",error:e.error},"*"):window.postMessage({action:"setI18nCallBack",callBack:!1},"*")}));break;case"getI18nLanguage":const t=e.data.uiLanguage;chrome.runtime.sendMessage(e.data.extensionId,{uiLanguage:t,action:"getI18nLanguage"},(e=>{chrome.runtime.lastError?window.postMessage({action:"getI18nLanguageCallBack",error:chrome.runtime.lastError.message},"*"):e?window.postMessage({action:"getI18nLanguageCallBack",languageList:e.languageList},"*"):e&&e.error?window.postMessage({action:"getI18nLanguageCallBack",error:e.error},"*"):window.postMessage({action:"getI18nLanguageCallBack",languageList:e.languageList},"*")}));break;case"sendExtensionId":const s=e.data.extensionId;chrome.runtime.sendMessage(s,{action:"checkPinned"},(e=>{chrome.runtime.lastError?window.postMessage({action:"checkPinnedResponse",error:chrome.runtime.lastError.message},"*"):e&&e.pinned?window.postMessage({action:"checkPinnedResponse",pinned:!0},"*"):e&&e.error?window.postMessage({action:"checkPinnedResponse",error:e.error},"*"):window.postMessage({action:"checkPinnedResponse",pinned:!1},"*")}));break;case"dt-web-login":const r=e.data.user;if(r&&void 0!==r.vipExpiryTimestamp){const e=Math.floor(Date.now()/1e3);r.isPro=r.vipExpiryTimestamp>0&&r.vipExpiryTimestamp>e}else r.isPro=!1;chrome.storage.local.set({userInfo:r}).then((()=>{window.postMessage({action:"dt-plugin-login-success"},window.location.href)}));break;case"dt-web-init":var i;(null===(i=twpConfig.get("userInfo"))||void 0===i?void 0:i.token)||window.postMessage({action:"dt-plugin-logout"},window.location.href);case"dt-web-routeToOptionsPage":chrome.runtime.sendMessage({action:"routeToOptionsPage"},(e=>{a(!0)}));break;case"dt-web-updateUserInfo":const c=o;if(c)if(void 0!==c.vipExpiryTimestamp){const e=Math.floor(Date.now()/1e3);c.isPro=c.vipExpiryTimestamp>0&&c.vipExpiryTimestamp>e}else c.isPro=!1;chrome.storage.local.set({userInfo:c}).then((()=>{a(!0)}))}})),initContentScript().then((e=>{const{tabUrl:n}=e;if(String(n).includes("telling-whip-450.notion.site")){const e=document.createElement("script");e.src=chrome.runtime.getURL("/contentScript/extern.js"),(document.head||document.documentElement).appendChild(e)}}))}();