Highlight node with chrome devtools extension [closed]

假如想象 提交于 2019-11-29 07:02:53

Whenever you evaluate some code in the inspected page using DevTools console, DevTools expose a bunch of helper calls known as command line API. This API includes inspect() call that has the same effect as if user invoked "Inspect Element" from the context menu, i.e. brings up the Elements panel and highlights the node. The inspect() call along with the rest of command line API is available to code evaluated by DevTools extnesions using chrome.devtools.inspectedWindow.eval(), so you can do stuff like:

chrome.devtools.inspectedWindow.eval("inspect(document.body)");

If you just want the highlight on the inspected page side, without anything happening on the Elements panel (i.e. as when you hover over the page with DOM search mode turned on by the looking glass in the Elements panel), you'll have to implement this on your own, as there's currently no API for that. I would suggest just adding a custom style to an element using a content script.

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