Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running singlefile-cli with a chrome extension #16

Open
klemenStanic opened this issue Feb 15, 2023 · 1 comment
Open

Running singlefile-cli with a chrome extension #16

klemenStanic opened this issue Feb 15, 2023 · 1 comment

Comments

@klemenStanic
Copy link

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?

@klemenStanic klemenStanic changed the title Running singlefile with a chrome extension Running singlefile-cli with a chrome extension Feb 15, 2023
@sdht0
Copy link

sdht0 commented Feb 16, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants