简体   繁体   中英

Shortcut for a Chrome Extension's background page?

I'm debugging an extension. Having to go to chrome://extensions, looking for your extension and clicking on "background page" every time you reload it gets annoying real quick.

Is there any shortcut to opening a specific extension's Developer Tools window?

I tried going to:

  • chrome-extension://[extension-id] -> "Your file was not found"
  • chrome-extension://[extension-id]/_generated_background_page.html -> Opens another background page.

When editing only the background page scripts, there's no need to reload the entire extension.
Simply keep the devtools open and reload the background page by pressing F5 key inside.

As for programmatic invocation of the background page, chrome.developerPrivate.openDevTools is showcased in Chrome Apps & Extensions Developer Tool app. Theoretically, you can make your own simple app (with like 10 lines of code) that reloads the extension and reopens its background page.
It requires whitelisting the app id and I'm not sure it'll work in this particular case (my quick test failed in the end even though whitelisting helped remove the permission error shown upon installation).

Perhaps you can use the "Chrome Apps & Extensions Developer Toolbar" tool which is available in the webstore at the below URL.

https://chrome.google.com/webstore/detail/chrome-apps-extensions-de/ohmmkhmmmpcnpikjeljgnaoabkaalbgc?hl=en

Features include,

  • Separate view for unpacked apps/extensions
  • Inspect views for inspecting app/extension pages using dev tools
  • Reload an app/extension
  • Launch an app/extension
  • View permissions
  • Pack an app/extension
  • Uninstall an app/extension
  • Load an unpacked app/extension
  • Search for app/extension

Hope this helps!

There seems to be no direct way. If you really wanna, I'd suggest adding an event listener to every open tab-- listening for your desired hotkey. If it fires you open the extensions tab and generate a click event on the "background page" element.

That window is opened by what seems to be a call to chrome.developerPrivate.openDevTools

If you try to call that from your background page or any web page other than chrome://extensions/ you'll learn that chrome.developerPrivate is undefined. It's supposedly available only in the devtools console and specifically whitelisted apps.

Found this kind of late: Chrome extension: how to programmatically inspect extension's background page

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