Yay a devtools!
This commit is contained in:
27
devtools/content.js
Normal file
27
devtools/content.js
Normal 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);
|
Reference in New Issue
Block a user