Initial commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
(() => {
|
||||
const KEY = "__cab";
|
||||
const host = location.hostname;
|
||||
if (!host) return;
|
||||
chrome.runtime.sendMessage({ cmd: "page", host, top: window === window.top }).then(res => {
|
||||
if (!res) return;
|
||||
const s = res.scriptlets && res.scriptlets.length ? JSON.stringify(res.scriptlets) : "";
|
||||
let prev = null;
|
||||
try { prev = localStorage.getItem(KEY); } catch (e) {}
|
||||
if (s === (prev || "")) return;
|
||||
try {
|
||||
if (s) localStorage.setItem(KEY, s);
|
||||
else localStorage.removeItem(KEY);
|
||||
} catch (e) {}
|
||||
if (s) window.dispatchEvent(new CustomEvent(KEY, { detail: s }));
|
||||
}).catch(() => {});
|
||||
})();
|
||||
Reference in New Issue
Block a user