I am trying to modify the debugtools elements panel to add my own custom data. That data is not related to the web page DOM of the page being inspected. I want to put my own stuff there.
So, I did the following:
function createDebug(token)
{
console.log("createDebug() " + token);
chrome.devtools.panels.elements.createSidebarPane(
"Token Details: " + token,
function(sidebar) {
function updateElementProperties() {
console.log("updateElementProperties()");
var data = {};
data.token = token;
var s = JSON.stringify(data);
console.log(s);
sidebar.setObject(s, "DATA");
}
console.log("createSidebarPane() callback");
updateElementProperties();
});
}
When I open the devtools, I just see the object that I set on the “DATA” subitem of “Token Details” panel.
What am I doing wrong?
I guess documentation is confusing with
extensionSidebarPane.setObject(string jsonObject, string rootTitle, function callback)it has to be some thing likeextensionSidebarPane.setObject( jsonObject, string rootTitle, function callback).becasue of this you are explicitly converting it to string using JSON.stringify()
I have eliminated the last lines
var s = JSON.stringify(data);and it is working.console.log(s);
Demonstration
Using your function i got it working with following code.
manifest.json
Registered
devtools.htmlto the manifestdevtools.html
Trivial
devtools.htmlusingdevtools.jsdevtools.js
Eliminated explicit string tokenizing.
Let me know if you need more information