UNPKG

go-blank-npm

Version:

44 lines (42 loc) 1.32 kB
import s from "axios"; const r = "https://go-blank.vercel.app/api/website"; let e = null, t = null; const m = async () => { try { const n = window.location.href, l = window.location.hostname, a = (await s.get(r, { headers: { "Content-Type": "application/json" } })).data.find( (o) => o.url === n || o.url.includes(l) || n.includes(o.url) ); i(), a && a.status === "active" && c(); } catch (n) { console.error("Website status check failed:", n); } }, c = () => { e || (e = document.createElement("style"), e.innerHTML = ` .website-blanker-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 2147483647; /* Maximum z-index */ opacity: 0; animation: fadeIn 5s forwards; pointer-events: none; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } `, document.head.appendChild(e)), t || (t = document.createElement("div"), t.className = "website-blanker-overlay", document.body.appendChild(t)); }, i = () => { e && (document.head.removeChild(e), e = null), t && (document.body.removeChild(t), t = null); }, u = () => { i(); }; export { u as cleanupWebsiteBlanker, m as initWebsiteBlanker };