google-chromegoogle-chrome-devtoolschrome-devtools-protocol

Chrome command line flag to open devtools window undocked


I know that I can open Chrome with the devtools dock placed to the right using the flag:

--auto-open-devtools-for-tabs

What I would like is to be able to modify the placement of the dock from the command line.

Is there any flag or configuration that would allow me to place the dock on startup wherever I want?

Or, can it be done using the Chrome Devtools Protocol?


Solution

  • It's also possible via nodejs and puppeteer, but you have to install puppeteer-extra (https://www.npmjs.com/package/puppeteer-extra) and the puppeteer-extra-plugin-user-preferences as well.

    The rest of the signature looks pretty similar to @ndbroadbent's answer

    puppeteer.use(puppeteerPrefs({
        userPrefs: {
            devtools: {
            preferences: {
                currentDockState: '"bottom"', // Double quotes?!?
                'panel-selectedTab' : '"console"'
            },
            },
        },
    }));
    

    Then you can do something like:

    browser = await puppeteer.launch({
        headless: "new",
        devtools: true,
        args: [ '--window-size=600,1260' ],
        defaultViewport: { width: 600, height: 1080 }
    });