From 24dea71e0f1da0c30e62cd0cc2ce1906be1ca02d Mon Sep 17 00:00:00 2001 From: AutoSponge Date: Thu, 23 Apr 2020 11:34:24 -0400 Subject: [PATCH] feat: add cli flag for running with aom --- bin/cli.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index e524439..9207ef9 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -17,6 +17,7 @@ const cli = meow( --browser, -b Change browsers (default: chromium) --no-js Disable JavaScript --no-csp Bypass CSP + --aom, -a Launch with Accessibility Object Model (AOM) enabled Examples $ scriptwriter $ scriptwriter --no-headless @@ -53,15 +54,19 @@ const cli = meow( type: 'boolean', default: false, }, + aom: { + type: 'boolean', + default: false, + alias: 'a', + }, }, } ); -const { config, browser, headless, csp, js, device } = cli.flags; +const { config, browser, headless, csp, js, device, aom } = cli.flags; const file = config ? require(resolve(config)) : {}; const use = (path, fallback) => dlv(file, path, fallback); - -const scriptwriter = new Scriptwriter({ +const normalizedConfig = { browserType: use('browserType', browser), launch: { headless: use('launch.headless', headless), @@ -72,5 +77,10 @@ const scriptwriter = new Scriptwriter({ javaScriptEnabled: use('context.javaScriptEnabled', js), }, device: use('device', device), -}); +}; +const aomFlag = '--enable-blink-features=AccessibilityObjectModel'; +if (aom && !normalizedConfig.launch.args.includes(aomFlag)) { + normalizedConfig.launch.args.push(aomFlag); +} +const scriptwriter = new Scriptwriter(normalizedConfig); scriptwriter.init();