问题
How does one programmatically open the Developer Tools window of a Chrome extension's background page using the Chrome Extensions API?
Essentially, I'm looking to achieve the programmatic equivalent of manually clicking on the "inspect background page" link of a given Chrome extension.
回答1:
Interesting question.
I don't think there is a way to do it; Google's own app, Chrome Apps & Extensions Developer Tool, uses a private API for this:
// Opens the devtools inspect window for the page.
chrome.developerPrivate.inspect({
extension_id: String(item.id),
render_process_id: String(view.render_process_id),
render_view_id: String(view.render_view_id),
incognito: view.incognito,
});
Obviously, this only works in specially-whitelisted apps and extensions.
来源:https://stackoverflow.com/questions/28064942/chrome-extension-how-to-programmatically-inspect-extensions-background-page