single-file-cli
single-file-cli copied to clipboard
Running singlefile-cli with a chrome extension
How do I run a chrome extension (e.g. IDontCareAboutCookies) within the webdriver? I tried running the single-file cli with
./single-file --browser-executable-path="/opt/google/chrome/google-chrome" --browser-args='["--no-sandbox", "--load-extension=./3.4.6_0.crx"]' https://www.bbc.com --dump-content
but the extension doesn't seem to work, and the returned single-file contains the popups. The path to the extension is correct. Any ideas?
Extensions cannot be run in headless mode, which single-file-cli
uses by default.
Here's what I use:
home_config="/home/<user>/.config"
ublock_path="$home_config/chromium/Default/Extensions/cjpalhdlnbpafiamejdnhcphjbkeiagm/1.44.2_1"
singlefile_opts=(
--browser-headless false
--browser-args '["--user-data-dir='$home_config'/chromium/Default","--disable-extensions-except='$ublock_path'","--load-extension='$ublock_path'"]'
)
single-file-cli "${singlefile_opts[@]}" <url>
In addition, I also had to do this once:
- Start chromium:
chromium --no-first-run --no-default-browser-check --user-data-dir=$home_config/chromium/Default --load-extension=$ublock_path
- Enable
Allow in Incognito
option for ublock as that is what single-file-cli uses in the latest code - Update the ublock filter lists manually.
Adapt to your extensions accordingly. If you also use chrome/chromium as your main browser, use a separate profile for single-file-cli
by creating one and changing the paths above.
Extensions can now be run in Chrome's new headless mode, see #83 for more details. This issue can be closed.
@aaviator42 Thank you for the reminder, I'm closing the issue.