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

expose path tbb_browser_dir #210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

milahu
Copy link

@milahu milahu commented Jun 17, 2024

on nixos linux
tbb_browser_dir is renamed from Browser to tor-browser
and all other paths are original

for example

$ ( cd /nix/store/sgixwgp3yf95dhi59661g2d11gh865vs-tor-browser-13.0.13/share && ls -d tor-browser/{firefox,fonts,TorBrowser,TorBrowser/Data/Browser/profile.default} )
tor-browser/firefox
tor-browser/fonts
tor-browser/TorBrowser
tor-browser/TorBrowser/Data/Browser/profile.default

so to avoid passing all paths to TorBrowserDriver
i made all paths relative to tbb_browser_dir

so now i can call

tbb_browser_dir = "..."
with TorBrowserDriver(tbb_browser_dir=tbb_browser_dir) as driver:
    # ...

i hope this also works for other users ...

also fix #209

with this patch, i can package tbselenium.nix with

{
  # set default paths
  postPatch = ''
    substituteInPlace tbselenium/tbdriver.py \
      --replace \
        'GECKO_DRIVER_EXE_PATH = shutil.which("geckodriver")' \
        'GECKO_DRIVER_EXE_PATH = "${geckodriver}/bin/geckodriver"' \
      --replace \
        'DEFAULT_TBB_BROWSER_DIR = ""' \
        'DEFAULT_TBB_BROWSER_DIR = "${tor-browser}/share/tor-browser"' \
  '';

with these default paths TorBrowserDriver works without any args

with TorBrowserDriver() as driver:
    driver.get("https://httpbin.org/ip")

os.chdir is not necessary
torbrowser already uses tbb_browser_dir as workdir
this is why tbb_browser_dir must be writable
probably to write .config/ and .tor project/

ensure writable tbb_browser_dir
fix: Your Tor Browser profile cannot be loaded

add DEFAULT_TBB_BROWSER_DIR

dont change workdir
@milahu milahu force-pushed the expose-paths-tbb_browser_dir-workdir branch from d3c41a0 to b4a3397 Compare June 19, 2024 11:48
@milahu milahu changed the title expose paths: tbb_browser_dir workdir expose path tbb_browser_dir Jun 19, 2024
@gunesacar
Copy link
Collaborator

#209 (comment)

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

Successfully merging this pull request may close these issues.

allow read-only tbb_path/Browser/
2 participants