how to customize rightclick on chrome devtools elements panel

杀马特。学长 韩版系。学妹 提交于 2019-12-22 18:56:08

问题


devtools elements panel right click

look at the image above. right clicking on any node displays menu of options like 'add attribute' and 'edit attribute' etc...

I want to be able to extend the right click menu to add my custom events. for example, I need to get the xpath of the node. I know I can extend the right click on actual page instead of extending right click on the source of the page.

https://developer.chrome.com/extensions/devtools_panels#type-ElementsPanel API's only supports selection change.


回答1:


Unfortunately, the Extending DevTools API doesn't expose the context menu from the internal DevTools source code. Sometimes the API documentation omits some available functions/properties, so I confirmed this with:

alert(Object.getOwnPropertyNames(chrome.devtools.panels.elements));

It returned onSelectionChanged,createSidebarPane only, which matches the documentation.

The WebInspector object in the DevTools source code has a populateNodeContextMenu function on WebInspector.ElementsTreeElement.prototype, but this cannot be accessed through the Extending DevTools API. It is completely separate.



来源:https://stackoverflow.com/questions/38016754/how-to-customize-rightclick-on-chrome-devtools-elements-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!