Using a Chrome extension to resize undocked dev tools window - google-chrome

There's a bug on Vivaldi browser which will probably remain unfixed for the upcoming months: undocked dev tools windows do not remember their previous size across tabs, so each time you open dev tools they are small. There's also another dev tools bug which I'd like to workaround which includes focusing the dev tools window. Those bugs are driving me nuts!
So, I tried to create a Chrome extension and see if that could catch the dev tools opening event and resize the dev tools undocked window.
The first part, I've done it by using a content script which catches f12 and ctrl+shift+i and other ways of opening dev tools. Then, the content script sends a message to a background script and it should resize the opened dev tools window.
Here's the problem: there doesn't seem to be any way to get opened dev tools window in Chrome Extension API.
I can get all the opened normal windows, but from that same API (chrome.windows) I can't find opened dev tools windows.
Is there any way one can access opened dev tools windows?
I tried using chrome.devtools API but that's only accessible inside dev tools panels.
Being this a private extension which will never get published, I can also try to use chrome.developerPrivate and other private APIs, but I don't know how to make them work.
Do you have any idea on how to proceed to get all opened dev tools windows? Could it be there isn't a way?
If there isn't a way, could you maybe point me in the right direction into using private Chrome APIs in any way?

Related

Chrome Dev Tools Snippets - AUTOSAVE

Is it possible to enable autosave on snippets in chrome dev tools?
It is infuriating when i accidentaly close a tab that dev tools was attached to where i had my snippets open and when i open dev tools again i've lost alot of work!
Are there any flags i can set to enable autosave or somehow get it to save when i run the snippet?
Just to be clear i am talking about the snippets under Sources/Snippets.
I know i can "just" use the shortcut ctrl-s to save however that is simply not good enough, i would atleast expect a recovery like all modern editors deliver.
Incase this cannot be achieved please point me the in direction where i can submit a feature request to the Chrome Dev Team
Select Tools > Developer Tools. The Developer Tools window opens as a docked panel at the side or bottom of Google Chrome. Click the Network tab. Select Preserve log.
Also, go to Settings in devtools, which is a little screw on the top-right corner, find the Console section under Preferences, and click on Preserve log upon navigation.
This has worked for me.

Chrome Firebug to take up window space

So in the Chrome version of Firebug, it's lying on top of the window, thus, if the whole window has text, you will have stuff hidden behind the firebug. Is it possible to get it to be like Firefox's version, where it is part of the window screen like the developer console? The options don't seem to point to anything that indicates this option.
The Chrome extension of Firebug is based on Firebug Lite, which is a JavaScript that is injected into the website. So, there is unfortunately no way to integrate it into Chrome's UI.
Furthermore, Firebug Lite (and with that the Chrome extension) is unmaintained for several years now, so it doesn't provide the features integrated developer tools have.
Alternatives are:
Chrome DevTools
Chrome has integrated developer tools, which provide a huge amount of features for web developers.
Firefox DevTools
The Firefox developer tools allow to debug Chrome (and other browsers) remotely. This doesn't work as good as the integrated tools and provides less features, but allows you to use the same tools to debug in different browsers.
debugger.html
The debugger.html project (developed by the Firefox DevTools team) picks up the idea of Firebug Lite by providing a browser independent UI. It's based on a local web server serving a website, which allows you to debug JavaScript code in different browsers by connecting to them remotely. Unfortunately, it currently only provides a JavaScript debugger and it's unclear whether it will be extended to cover other features like an HTML inspector panel, a network panel, etc. later.

How can I change icon for Chrome Developer Tools?

As you probably know, Chrome Dev Tools has the same icon as browser itself. In order, to increase productivity I would like to change it's icon, so it will be easier to find it in the taskbar.
Thanks in advance.
Give this a try:
Open up Chrome and then open up developer tools in another window so that you have two Chrome icons on your taskbar. Right click the devtools one and Pin to taskbar.
Right click on the newly pinned icon, right click on Google Chrome (2) and properties.
Under Shortcut->Change Icon, pick something else. Then 'OK' out.
You'll need to restart explorer.exe, so open Windows Task manager, kill explorer.exe and restart it.
You'll now see two different icons.
Do this: Start regular Chrome. Then CTRL+Shift+i and it should open devtools as the new icon.
Unfortunately, clicking the devtools icon initially will not open devtools on startup. Supposedly you can change the properties to start using chrome.exe --args --auto-open-devtools-for-tabs but I was unable to make that work.
YMMV with your operating system but this works with Windows 7. Hope that helps.
Note: If you're using Windows 10, you won't see explorer in the task manager by default, you have to click "More details" on the bottom and switch to the "Details" tab.
Alternatively, open PowerShell and type:
Get-Process explorer -ErrorAction SilentlyContinue | Stop-Process
This will kill explorer, and windows will automatically restart it
This answer may be a nice work around for non-Windows users who are debugging from Visual Studio Code. It uses Chrome's Canary build for debugging. It has a different icon so telling it apart from regular Chrome should be easy.
This answer talks about setting the executable to Canary which is easily distinguishable from regular Chrome. You will need to download the Canary version of Chrome first.
settings.json:
"runtimeExecutable": "canary"
How to configure Visual Studio Code debugger to use Chrome Canary?

Disabling inspect element, right click and F12 in google chrome

Is there a way to disable inspect element, right click and F12 in google chrome?
This is definitely not possible to do from a web page.
Even if you disable right click and disable the default behaviors for F12, Ctrl+Shift+I, and Ctrl+Shift+J, there is no way to stop a user from opening Dev Tools on a different page and navigating to your page with Dev Tools already open.
Also, you can access Dev Tools by going to Menu > Tools > Developer tools, which cannot be prevented by any website.
You can run chromium in a java environment. This I have seen, then its impossible to open developer tools, and settings etc are not accessable. But of course it would involve a lot more work and development time.

How do you inspect the web inspector in Chrome?

According to Google this can be accomplished by visiting "chrome-devtools://devtools/devtools.html" in Chrome but now visiting that page in the stable version of Chrome (or Canary), just shows a 99% stripped version of the inspector.
To reiterate my "title" this is in reference to "inspecting" the inspector. Not just inspecting a normal webpage.
And while I don't think it's necessary to know to resolve the issue, I"m inspecting the inspector so I can style it as discussed by Paul Irish and here: https://darcyclarke.me/articles/development/skin-your-chrome-inspector/
Follow these easy steps!
Press Command+Option+i (Ctrl+Shift+i on Windows) to open DevTools.
Make sure that the developer tools are undocked into a new window. You may have to undock from the menu:
Press Command+Option+i again on this new window.
That will open the DevTools on the DevTools.
You can redock the page's DevTools if you want.
If it's not already, select Elements — it's the first icon at the top of the inspector.
A little beyond the scope of your question, but still valid in understanding why you're experiencing your problem can be found by understanding how Chrome Developer Tools: Remote Debugging works.
Open chrome://inspect
Open the inspector on that page (cmd + alt + i)
Scroll to the bottom of the page, under the Other section click the inspect link
The URL in the Other section should look something like this:
chrome-devtools://devtools/devtools.html?docked=true&dockSide=bottom&toolbarColor=rgba(230,230,230,1…
EDIT: they've fancied up the chrome:inspect page so you have to click the Other header on the left to get this to work now.
I just got this to work. The key is that you have to start up chrome in 'Remote Debugging' mode.
on OSX, open an terminal window and execute the following:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
On windows, Its
chrome.exe --remote-debugging-port=9222
(better windows instructions can be found here: https://developers.google.com/chrome-developer-tools/docs/remote-debugging#remote)
This will start up an instance of chrome, that will send debugging messages to a local webserver on port 9222.
If you access that web service, it will give you the ability to use the inspector to inspect any chrome window that is running. Since we want to inspect the inspector, we need to start an inspector window first (As above Use the shortcut keys; for Mac it's Command+option+i.)
Now, go ahead and navigate to
http://localhost:9222
It will present you with a list of windows to display in the debugger. Select the window that starts with "Developer Tools" and you'll be able to inspect the css for the inspector.
Its hard to see in the image below, but on the left I have my chrome window pointing at the remote debugger, highlighting one of the toolbar labels. On the right you see it lit up with the tooltip just as if we were debugging a web page.
A few weeks ago somebody pointed this out in stackoverflow's "javscript" chatroom. First, and very importantly, make sure the inspector is undocked from your browser window. Then it's just a matter of opening a inspector window and then inspecting that window. In windows it's CtrlShiftI (Edit: I said, CtrlShiftI but that brings up the console inspecting the console... you should be able to navigate back and forth.) for the keyboard shortcut. (Other keyboard combos for other options and OSes here and here.) Just do that twice and you're good.
Edit: ok, you're probably confused as to undock the window. This is what you'd click if it's docked..
Edit II: I'm not quite sure why you can't inspect. JDavis's answer is consistent with the Google Docs for Apple computers. If you're using Linux it appears to be the same as Windows. You supposed to hit the inspector key combination while the focus is over the inspector window.