Opening devtools from the extension

706 views
Skip to first unread message

Moran Fine

unread,
Apr 27, 2023, 7:34:24 AM4/27/23
to Chromium Extensions
Does anyone know how can I open the Chrome devtools from the extension? Is it possible maybe with CDP?

wOxxOm

unread,
Apr 27, 2023, 2:00:45 PM4/27/23
to Chromium Extensions, Moran Fine
No, it's not possible (intentionally), https://crbug.com/445240

wOxxOm

unread,
Apr 27, 2023, 2:24:32 PM4/27/23
to Chromium Extensions, wOxxOm, Moran Fine
You can probably use chrome.developerPrivate.openDevTools in a local unpacked extension if you start chrome with a command line switch --whitelisted-extension-id=ID or --allowlisted-extension-id=ID. Check the source of devtools frontend to see how this method is called.

Cuyler Stuwe

unread,
Apr 27, 2023, 9:39:46 PM4/27/23
to Chromium Extensions, wOxxOm, Moran Fine

I tried this out of curiosity in Canary (115), and while I did get some other private APIs surfaced, chrome.developerPrivate was still undefined.

Moran Fine

unread,
Apr 30, 2023, 2:46:49 AM4/30/23
to Chromium Extensions, Cuyler Stuwe, wOxxOm, Moran Fine
Thanks a lot for the replies!
So let's say I'm asking the user to open the Chrome devtools, is there a way that I can check that the Chrome devtools is now open?

wOxxOm

unread,
Apr 30, 2023, 10:09:17 AM4/30/23
to Chromium Extensions, Moran Fine, Cuyler Stuwe, wOxxOm

Moran Fine

unread,
Apr 30, 2023, 2:15:08 PM4/30/23
to Chromium Extensions, wOxxOm, Moran Fine, Cuyler Stuwe
Thanks. I need to check if the Chrome devtools is open on the web page from an extension, and it didn't work for me with this solution. Is there a way to check it from an extension?

Deco

unread,
May 2, 2023, 5:40:15 AM5/2/23
to Moran Fine, Chromium Extensions, wOxxOm, Cuyler Stuwe
Yes you can use  chrome.devtools.inspectedWindow.eval("!!(window.devtools)" to explicitly check if the extension is open, e.g:
chrome.devtools.inspectedWindow.eval("!!(window.devtools)", function(result, isException) { if (!isException && result) { console.log("DevTools are open"); } else { console.log("DevTools are closed"); } });

The thread isn't exactly clear why you want this utility, but based on an assumption for your use case take explicit note of the use of getResources within the documentation

Thanks,
Deco

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/e01d5c54-21a4-4146-aa62-40c59e59d589n%40chromium.org.

Deco

unread,
May 2, 2023, 5:41:14 AM5/2/23
to Moran Fine, Chromium Extensions, wOxxOm, Cuyler Stuwe
Typo error: " check if the extension is open" to " "check if the devtools panel is open from an extension programmatically". 

Thanks,
Deco
Reply all
Reply to author
Forward
0 new messages