简体   繁体   中英

Go to source code line in Chrome dev tools extension?

I want to make a dev tools Chrome extension that lets the user go to specific points in the page's source code (whenever the page's source code calls some global function foo that I inject into the page via an extension content script).

I can get a stack trace by having function foo throw an exception and then catch it.

But how can I tell Chrome dev tools to go navigate to a certain line in the source code? Is there an API call for that?

There's an API function just for that, chrome.devtools.panels.openResource .
Note that line numbers are zero-based for this API.

// Opens line 34 of file https://example.com/test.js, assuming this resource is present:
chrome.devtools.panels.openResource("https://example.com/test.js", 33, function() {
  // Resource should be open, but no way to test that it succeeded
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM