2016-06-24 28 views
2

devtools elements panel right click如何在Chrome devtools元素面板上自定義rightclick

看看上面的圖片。右鍵點擊任何節點會顯示選項菜單,如「添加屬性」和「編輯屬性」等...

我希望能夠擴展右鍵菜單來添加我的自定義事件。例如, ,我需要獲取節點的xpath。 我知道我可以在實際頁面上擴展右鍵,而不是在頁面的源代碼上右鍵單擊。

https://developer.chrome.com/extensions/devtools_panels#type-ElementsPanel API僅支持選擇更改。

回答

1

不幸的是,Extending DevTools API沒有公開內部DevTools源代碼的上下文菜單。有時,API文檔省略了一些可用的功能/性能,所以我證實了這一點有:

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

它只返回onSelectionChanged,createSidebarPane,該文件相匹配。

DevTools源代碼中的WebInspector對象在WebInspector.ElementsTreeElement.prototype上有一個populateNodeContextMenu函數,但無法通過Extending DevTools API進行訪問。它是完全分開的。

enter image description here

相關問題