Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

possible to refresh chrome dev tools watch expressions manually or by code?

Taking a look at https://developer.chrome.com/devtools/docs/tips-and-tricks#favorite-expression

If I don't set any breakpoints, then I have to manually click on the refresh icon in the watch expressions panel. It would be nice if I could put in some debugging code to update the watch expressions without ever having to enter debug mode.

Something like this:

// some update function
setInterval(function() {
    console.refresh();
}, 1000);
like image 800
ilovett Avatar asked Jun 27 '14 21:06

ilovett


People also ask

How do I refresh the developer tools in Chrome?

Or, Hold down Ctrl and press F5. Just open the Chrome Dev Tools by pressing F12. Once the chrome dev tools are open, just right click on the refresh button and a menu will drop down. This menu gives you the option of doing a hard refresh, or even clearing the cache and do a hard refresh automatically.

How do I refresh inspect element?

Right-click on the screen and choose Inspect element. Click on Console tab. Reload the page.

Which command is used for display current expression in Inspect Element in Chrome?

F12, or Ctrl + Shift + I to open the Developer Tools. Ctrl + Shift + J to open the Developer Tools and bring focus to the Console. Ctrl + Shift + C to open the Developer Tools in Inspect Element mode, or toggle Inspect Element mode if the Developer Tools are already open.


1 Answers

update

Check out Live Expressions. These are similar to Watch Expressions, expect they're in the Console and they update in real-time.

original

wOxxOm's hack for displaying the average FPS of a Performance recording gave me inspiration on how we could hack together a solution to this problem:

  1. Open DevTools.
  2. Click the Sources tab to open the Sources panel. You can navigate to other panels, but you have to open Sources at least once before running the code below. I'll explain why you have to do this later.
  3. Undock your DevTools window.
  4. Focus your DevTools window, then press Control+Shift+J (Windows, Linux) or Command+Option+J (Mac). Another DevTools window opens up. This second window is inspecting your first DevTools window. This works because DevTools itself is just a web app.
  5. In the second DevTools window, run this code in the Console:

    let id;
    UI.panels.sources._watchSidebarPane.widget().then(ui => {
        id = setInterval(() => {
            ui._refreshButton.element.click();
        }, 1000);
    });
    

We essentially just set a timer to click the "Refresh Watch Expressions" button every second.

Here's an example of the hack in action: https://youtu.be/w-3rqFhziQ4

The reason you have to open the Sources panel before running the code is because the UI.panels object only contains panels that you've opened. If you don't open Sources, the reference to UI.panels.sources will be undefined.

like image 180
Kayce Basques Avatar answered Oct 08 '22 18:10

Kayce Basques