Skip to content

Instantly share code, notes, and snippets.

@jaminmc
Last active March 7, 2024 19:18
Show Gist options
  • Save jaminmc/ae415a3388e6fc4192892d56b3454089 to your computer and use it in GitHub Desktop.
Save jaminmc/ae415a3388e6fc4192892d56b3454089 to your computer and use it in GitHub Desktop.
Install chromedriver that matches Brave-Browser on Linux!
#!/bin/bash
# Create a temporary directory for downloads
temp_dir=$(mktemp -d)
trap "rm -rf $temp_dir" EXIT
brave_path="$(command -v brave-browser)"
brave_path="$(readlink -f "$brave_path")"
brave_path="$(dirname "$brave_path")/brave"
# Extract Chromium version from Brave binary
chromium_version=$(strings "$brave_path" | grep "Chromium:" | awk '{print $NF}' | cut -d'.' -f1-3)
echo "chromium_version: $chromium_version"
# Download corresponding ChromeDriver version
chromedriver_url="$(
curl -s "https://googlechromelabs.github.io/chrome-for-testing/$(curl -s https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_$chromium_version).json" | jq -r '.downloads.chromedriver[] | select(.platform == "linux64") | .url'
)"
echo "chromedriver_url: $chromedriver_url"
# Set up paths for downloading and extraction
chromedriver_zip="$temp_dir/chromedriver.zip"
chromedriver_dir="$temp_dir/chromedriver"
# Download and extract ChromeDriver
echo "Downloading ChromeDriver version ${chromium_version}..."
wget -O "$chromedriver_zip" "$chromedriver_url"
unzip -j "$chromedriver_zip" -d "$chromedriver_dir"
# Make chromedriver executable
chmod +x "$chromedriver_dir/chromedriver"
# Move chromedriver to the desired installation directory
install_dir="/usr/local/bin"
echo "Installing ChromeDriver to $install_dir"
sudo mv "$chromedriver_dir/chromedriver" "$install_dir"
echo "ChromeDriver installation completed successfully."
@jaminmc
Copy link
Author

jaminmc commented Mar 7, 2024

This was only rested on Debian, and it requires: jq, curl, wget, and, of course, brave-browser to be installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment