簡體   English   中英

定義 Chrome DevTools window 的默認寬度

[英]Define default width of Chrome DevTools window

有沒有辦法為 chrome 提供 devtools window 的默認寬度。 就像現在一樣,當我啟動 chrome 並打開 DevTools 時,它大約需要 window 寬度的一半。 理想情況下,我會做類似的事情

$> /Applications/Google Chrome.app/Contents/MacOS/"Google Chrome" 
      --devtools-width=300

並告訴它寬度是多少。

為了提供一些上下文,我正在運行 Puppeteer,就我而言,它在啟動瀏覽器時會打開 DevTools。 但它對我來說太寬了,我每次都需要調整它的大小。 這是我的配置:

await puppeteer.launch({
        headless: false,
        devtools: true,
        defaultViewport: null,
        executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
        args: [
            '--debug-devtools',
            '--no-sandbox',
            '--disable-setuid-sandbox',
            '--disable-web-security',
            '--allow-running-insecure-content',
            '--disable-notifications',
            '--window-size=1920,1080'
        ]
    });

但我認為這不是一個木偶問題。

puppeteer-extrapuppeteer-extra-plugin-user-preferences一起使用並指定splitViewState

package.json 依賴項:

"puppeteer": "^1.20.0",
"puppeteer-extra": "^2.1.3",
"puppeteer-extra-plugin-user-data-dir": "^2.1.2",
"puppeteer-extra-plugin-user-preferences": "^2.1.2"

用法:

const puppeteer = require('puppeteer-extra');
const ppUserPrefs = require('puppeteer-extra-plugin-user-preferences');

puppeteer.use(ppUserPrefs({
  userPrefs: {
    devtools: {
      preferences: {
        'InspectorView.splitViewState': JSON.stringify({
          vertical: {size: 300},
          horizontal: {size: 0},
        }),
        uiTheme: '"dark"',
      },
    },
  },
}));

puppeteer.launch({
  headless: false,
  devtools: true,
  defaultViewport: null,
  args: [
    '--window-size=1920,1080',
  ],
});

PS 查看完整列表,將您的Preferences的內容復制粘貼到瀏覽器配置文件目錄中,並使用任何 JSON 美化器對其進行格式化,然后在里面查找devtoolspreferences

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM