首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >定义Chrome DevTools窗口的默认宽度

定义Chrome DevTools窗口的默认宽度
EN

Stack Overflow用户
提问于 2019-10-20 12:51:16
回答 1查看 1.3K关注 0票数 4

是否有方法为devtools窗口提供默认宽度。就像现在一样,当我启动chrome并打开DevTools时,它的宽度大约是窗口宽度的一半。理想情况下,我会做这样的事情

代码语言:javascript
复制
$> /Applications/Google Chrome.app/Contents/MacOS/"Google Chrome" 
      --devtools-width=300

告诉它宽度是多少。

为了给出一些上下文,我正在运行Puppeteer,在我的例子中,它在启动浏览器时打开DevTools。但对我来说太宽了,我每次都要调整尺寸。这是我的配置:

代码语言:javascript
复制
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'
        ]
    });

但我认为这不是木偶师的问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-20 13:39:58

木偶师-额外木偶师.插件.用户偏好一起使用并指定splitViewState

package.json依赖关系:

代码语言:javascript
复制
"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"

用法:

代码语言:javascript
复制
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',
  ],
});

要查看完整列表,请在浏览器配置文件目录中复制Preferences的内容,并将其格式化为任何JSON,然后在其中查找devtoolspreferences

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58473161

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档