简体   繁体   English

转到Chrome开发工具扩展程序中的源代码行?

[英]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). 我想制作一个开发工具Chrome扩展程序 ,让用户可以访问页面源代码中的特定点(每当页面的源代码调用我通过扩展内容脚本注入页面的某个全局函数foo )。

I can get a stack trace by having function foo throw an exception and then catch it. 我可以通过让函数foo抛出异常然后捕获它来获得堆栈跟踪。

But how can I tell Chrome dev tools to go navigate to a certain line in the source code? 但是,如何告诉Chrome开发工具导航到源代码中的某一行? Is there an API call for that? 是否有API调用?

There's an API function just for that, chrome.devtools.panels.openResource . 有一个API函数, chrome.devtools.panels.openResource
Note that line numbers are zero-based for this API. 请注意,此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
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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