trainsim/devtools/content.js
2025-02-15 13:11:38 -07:00

21 lines
670 B
JavaScript

browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "GET_CONTEXT_STACK") {
const contextStack = window.wrappedJSObject.getContextStack();
sendResponse({ contextStack });
} else if (message.type === "UPDATE_CONTEXT_VALUE") {
const { key, value, depth } = message;
if (window.wrappedJSObject.updateContextValue) {
window.wrappedJSObject.updateContextValue(key, value, depth);
sendResponse({ success: true });
} else {
sendResponse({
success: false,
error: "updateContextValue not defined",
});
}
}
});
browser.runtime.sendMessage({ type: "PAGE_LOADED" });