diff --git a/plugin/lib/quickcomposer/browser/browser.js b/plugin/lib/quickcomposer/browser/browser.js index 7c688ae..7ef9784 100644 --- a/plugin/lib/quickcomposer/browser/browser.js +++ b/plugin/lib/quickcomposer/browser/browser.js @@ -107,10 +107,11 @@ const launchBrowser = async (options) => { const { browserType = "msedge", useSingleUserDataDir = true, - headless = false, proxy = null, browserPath = getBrowserPath(browserType), windowSize = null, + incognito = false, + headless = false, } = options; if (!browserPath) { @@ -119,14 +120,28 @@ const launchBrowser = async (options) => { const port = await findAvailablePort(9222); - const args = [ + const automationArgs = [ `--remote-debugging-port=${port}`, + "--disable-infobars", + "--disable-notifications", + "--disable-popup-blocking", + "--disable-save-password-bubble", + "--disable-translate", "--no-first-run", "--no-default-browser-check", - "--start-maximized", - headless ? "--headless" : "", - windowSize ? `--window-size=${windowSize}` : "", + "--user-data-start-with-quickcomposer", + ]; + + const incognitoArg = { + chrome: "--incognito", + msedge: "--inprivate", + }; + + const optionArgs = [ + windowSize ? `--window-size=${windowSize}` : "--start-maximized", proxy ? `--proxy-server=${proxy}` : "", + incognito ? incognitoArg[browserType] : "", + headless ? "--headless" : "", useSingleUserDataDir ? `--user-data-dir=${path.join( os.tmpdir(), @@ -135,6 +150,8 @@ const launchBrowser = async (options) => { : "", ].filter(Boolean); + const args = [...automationArgs, ...optionArgs]; + return new Promise(async (resolve, reject) => { if (!useSingleUserDataDir) { try { diff --git a/src/js/composer/commands/browserCommands.js b/src/js/composer/commands/browserCommands.js index e3e122b..a97b4ba 100644 --- a/src/js/composer/commands/browserCommands.js +++ b/src/js/composer/commands/browserCommands.js @@ -55,12 +55,17 @@ export const browserCommands = { useSingleUserDataDir: { label: "使用独立用户数据目录", component: "CheckButton", - width: 6, + width: 4, }, headless: { - label: "启用无头模式", + label: "无头模式", component: "CheckButton", - width: 6, + width: 4, + }, + incognito: { + label: "隐身模式", + component: "CheckButton", + width: 4, }, windowSize: { label: "窗口尺寸", @@ -97,6 +102,7 @@ export const browserCommands = { browserType: "msedge", useSingleUserDataDir: true, headless: false, + incognito: false, }, }, ],