Yay a devtools!

This commit is contained in:
2025-02-15 12:46:14 -07:00
parent 8e6294c96f
commit 9124abb749
9 changed files with 303 additions and 0 deletions

27
devtools/content.js Normal file
View File

@@ -0,0 +1,27 @@
console.log("content.js loaded", window.wrappedJSObject);
// setTimeout(() => {
const getContextStack = () => window.wrappedJSObject.getContextStack();
const updateContextValue = (key, value, depth) =>
window.wrappedJSObject.updateContextValue(key, value, depth);
console.log(getContextStack());
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "GET_CONTEXT_STACK") {
const contextStack = getContextStack();
sendResponse({ contextStack });
} else if (message.type === "UPDATE_CONTEXT_VALUE") {
const { key, value, depth } = message;
if (glowindow.updateContextValue) {
updateContextValue(key, value, depth);
sendResponse({ success: true });
} else {
sendResponse({
success: false,
error: "updateContextValue not defined",
});
}
}
});
// }, 0);