From 3bb3e218da494d01bee64423c4b190a5c651b494 Mon Sep 17 00:00:00 2001 From: Luckz <224748+Luckz@users.noreply.github.com> Date: Sat, 8 Oct 2022 09:20:41 +0200 Subject: [PATCH 1/2] add browser_userdata to config, to set puppeteer's userDataDir Otherwise, two --user-data-dir are sent to Chrome, which has unexpected effects. --- README.md | 2 ++ src/index.tsx | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e282b6..bef047c 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,8 @@ Below is a list of all available options. `‑‑browser‑args ` | `browser_args` Extra arguments to pass to the browser instance. If provided as a command line argument, this should be a comma-separated list of args. Note that `\ ` is used as an escape character so if you want to use a comma in one of the args, it needs to be escaped so this `--some-arg=a,b,c` would be `--some-arg=a\,b\,c` If provided in the JSON config, this should be an array of strings. +`‑‑browser‑userdata ` | `browser_args` If set, use a custom folder as your Chrome profile `--user-data-dir`. By default, Puppeteer will create a fresh folder with a randomized name on each start. + `‑‑watch‑unlisted‑games` | `watch_unlisted_games` When `true`, the app will watch streams of games that are not listed in the config if the listed games' campaigns are completed or no streams are active. - Default: `false` diff --git a/src/index.tsx b/src/index.tsx index 3505b62..1f875b1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -294,6 +294,7 @@ const options = [ new IntegerOption("--failed-stream-retry", {defaultValue: 3}), new IntegerOption("--failed-stream-timeout", {defaultValue: 30}), new StringListOption("--browser-args"), + new StringOption("--browser-userdata"), /* new BooleanOption('--update-games', null, false), TODO: auto update games.csv ? */ new BooleanOption("--watch-unlisted-games"), new BooleanOption("--hide-video"), @@ -356,6 +357,7 @@ export interface Config { failed_stream_retry: number, failed_stream_timeout: number, browser_args: string[], + browser_userdata: string, watch_unlisted_games: boolean, hide_video: boolean, cookies_path: string, @@ -532,7 +534,8 @@ async function main(): Promise { const browser = await puppeteer.launch({ headless: config["headless"], executablePath: config["browser"], - args: config["browser_args"] + args: config["browser_args"], + ...(config["browser_userdata"] && { userDataDir: config["browser_userdata"]}) }); // Automatically stop this program if the browser is closed @@ -630,7 +633,8 @@ async function main(): Promise { loginBrowser = await puppeteer.launch({ headless: false, executablePath: config["browser"], - args: config["browser_args"] + args: config["browser_args"], + ...(config["browser_userdata"] && { userDataDir: config["browser_userdata"]}) }); } From b03d3a825d0bd2e25e5bcef6468b458a79890880 Mon Sep 17 00:00:00 2001 From: Luckz <224748+Luckz@users.noreply.github.com> Date: Sat, 8 Oct 2022 09:44:15 +0200 Subject: [PATCH 2/2] add userdata multi-account warning to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bef047c..cce4a80 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ Below is a list of all available options. `‑‑browser‑args ` | `browser_args` Extra arguments to pass to the browser instance. If provided as a command line argument, this should be a comma-separated list of args. Note that `\ ` is used as an escape character so if you want to use a comma in one of the args, it needs to be escaped so this `--some-arg=a,b,c` would be `--some-arg=a\,b\,c` If provided in the JSON config, this should be an array of strings. -`‑‑browser‑userdata ` | `browser_args` If set, use a custom folder as your Chrome profile `--user-data-dir`. By default, Puppeteer will create a fresh folder with a randomized name on each start. +`‑‑browser‑userdata ` | `browser_args` If set, use a custom folder as your Chrome profile `--user-data-dir`. By default, Puppeteer will create a fresh folder with a randomized name on each start. If you set this option, and you idle for drops on multiple Twitch accounts by running multiple instaces of Twitch Drops Bot, be careful not to set the same folder for multiple accounts. `‑‑watch‑unlisted‑games` | `watch_unlisted_games` When `true`, the app will watch streams of games that are not listed in the config if the listed games' campaigns are completed or no streams are active.