javiotic-codes
javiotic-codes

Reputation: 467

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:

Upvotes: 2

Views: 1564

Answers (3)

woxxom
woxxom

Reputation: 73616

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).

Upvotes: 3

kundrata
kundrata

Reputation: 679

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

Upvotes: 0

David R
David R

Reputation: 15647

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!

Upvotes: 1

Related Questions