In my Google Chrome DevTools Extension I try to listen to the selections in the DevTools panel "Elements". In particular, it should be possible to listen to the selection of the already selected element.
My goal is to somehow listen to every click/selection in the elements panel. In summary, I am looking for an onSelection
listener instead of an onSelectonChange
listener.
chrome.devtools.panels.elements.createSidebarPane(
"Selector",
function(sidebar) {
// It fires if I'm selecting a specific DOM element via the elements panel the first time
// It won't fire if I'm selecting the same DOM element again
chrome.devtools.panels.elements.onSelectionChanged.addListener(() => {
chrome.devtools.inspectedWindow.eval(`(${getSelector})()`,
selector => {
console.log(selector)
// Here I tried to reset the current selection...
// I've already debugged it: I can assign a value to $0,
// but this implies that the value remains constant even
// after a new selection.
chrome.devtools.inspectedWindow.eval('$0 = undefined')
})
})
}
)
I am wondering if there is a way to change the selector programmatically...