| | #!/bin/bash |
| |
|
| | |
| | |
| | |
| |
|
| | set -e |
| |
|
| | PROFILE_DIR="$HOME/.config/google-chrome-headers" |
| | EXTENSION_DIR="$PROFILE_DIR/HeaderModifier" |
| |
|
| | echo "================================================" |
| | echo "Automated Header Modifier Setup for Chrome" |
| | echo "================================================" |
| | echo "" |
| |
|
| | |
| | echo "[1/3] Checking for Google Chrome..." |
| | if ! command -v google-chrome &> /dev/null; then |
| | echo "Installing Google Chrome..." |
| | wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - |
| | sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' |
| | sudo apt-get update |
| | sudo apt-get install -y google-chrome-stable |
| | echo "✓ Chrome installed" |
| | else |
| | echo "✓ Chrome already installed" |
| | fi |
| |
|
| | |
| | echo "" |
| | echo "[2/3] Creating header modifier extension..." |
| | rm -rf "$EXTENSION_DIR" |
| | mkdir -p "$EXTENSION_DIR" |
| |
|
| | |
| | cat > "$EXTENSION_DIR/manifest.json" << 'EOF' |
| | { |
| | "manifest_version": 3, |
| | "name": "Header Modifier", |
| | "version": "1.0.0", |
| | "description": "Automatically modifies User-Agent and Sec-Ch-Ua-Platform headers", |
| | "permissions": [ |
| | "declarativeNetRequest" |
| | ], |
| | "host_permissions": [ |
| | "<all_urls>" |
| | ], |
| | "declarative_net_request": { |
| | "rule_resources": [{ |
| | "id": "ruleset_1", |
| | "enabled": true, |
| | "path": "rules.json" |
| | }] |
| | }, |
| | "background": { |
| | "service_worker": "background.js" |
| | } |
| | } |
| | EOF |
| |
|
| | |
| | cat > "$EXTENSION_DIR/rules.json" << 'EOF' |
| | [ |
| | { |
| | "id": 1, |
| | "priority": 1, |
| | "action": { |
| | "type": "modifyHeaders", |
| | "requestHeaders": [ |
| | { |
| | "header": "User-Agent", |
| | "operation": "set", |
| | "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" |
| | }, |
| | { |
| | "header": "Sec-Ch-Ua-Platform", |
| | "operation": "set", |
| | "value": "\"macOS\"" |
| | }, |
| | { |
| | "header": "Sec-Ch-Ua", |
| | "operation": "set", |
| | "value": "Not(A:Brand\";v=\"8\", \"Chromium\";v=\"144\", \"Google Chrome\";v=\"144\"" |
| | } |
| | ] |
| | }, |
| | "condition": { |
| | "urlFilter": "*", |
| | "resourceTypes": [ |
| | "main_frame", |
| | "sub_frame", |
| | "stylesheet", |
| | "script", |
| | "image", |
| | "font", |
| | "object", |
| | "xmlhttprequest", |
| | "ping", |
| | "csp_report", |
| | "media", |
| | "websocket", |
| | "other" |
| | ] |
| | } |
| | } |
| | ] |
| | EOF |
| |
|
| | |
| | cat > "$EXTENSION_DIR/background.js" << 'EOF' |
| | // Background service worker for Header Modifier |
| | console.log('Header Modifier extension loaded'); |
| |
|
| | // Listen for extension installation |
| | chrome.runtime.onInstalled.addListener(() => { |
| | console.log('Header Modifier installed and active'); |
| | console.log('User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36'); |
| | console.log('Sec-Ch-Ua-Platform: "macOS"'); |
| | }); |
| | EOF |
| |
|
| | echo "✓ Extension created at $EXTENSION_DIR" |
| |
|
| | # Create Chrome preferences to suppress popups |
| | echo "" |
| | echo "[3/4] Configuring Chrome preferences..." |
| | mkdir -p "$PROFILE_DIR/Default" |
| |
|
| | cat > "$PROFILE_DIR/Default/Preferences" << 'PREFEOF' |
| | { |
| | "browser": { |
| | "show_home_button": true, |
| | "check_default_browser": false |
| | }, |
| | "profile": { |
| | "default_content_setting_values": { |
| | "notifications": 2 |
| | }, |
| | "password_manager_enabled": false, |
| | "name": "HeaderModifier" |
| | }, |
| | "upgrade": { |
| | "last_check_status": 0, |
| | "last_check_time": "13317768000000000" |
| | }, |
| | "distribution": { |
| | "skip_first_run_ui": true, |
| | "show_welcome_page": false, |
| | "import_search_engine": false, |
| | "import_history": false, |
| | "do_not_create_any_shortcuts": true, |
| | "do_not_create_desktop_shortcut": true, |
| | "do_not_create_quick_launch_shortcut": true, |
| | "do_not_create_taskbar_shortcut": true, |
| | "do_not_launch_chrome": true, |
| | "do_not_register_for_update_launch": true, |
| | "make_chrome_default": false, |
| | "make_chrome_default_for_user": false, |
| | "suppress_first_run_default_browser_prompt": true |
| | }, |
| | "first_run_tabs": [], |
| | "sync_promo": { |
| | "show_on_first_run_allowed": false |
| | }, |
| | "privacy_sandbox": { |
| | "m1": { |
| | "topics_enabled": false, |
| | "fledge_enabled": false |
| | }, |
| | "notice_displayed": true, |
| | "consent_decision_made": true, |
| | "topics_consent": { |
| | "consent_given": false |
| | } |
| | } |
| | } |
| | PREFEOF |
| |
|
| | cat > "$PROFILE_DIR/First Run" << 'EOF' |
| | EOF |
| |
|
| | cat > "$PROFILE_DIR/First Run Dev" << 'EOF' |
| | EOF |
| |
|
| | echo "✓ Preferences configured" |
| |
|
| | # Create launcher script |
| | echo "" |
| | echo "[4/4] Creating launcher script..." |
| | LAUNCH_SCRIPT="$HOME/launch-chrome-with-headers-hijack.sh" |
| | cat > "$LAUNCH_SCRIPT" << EOF |
| | #!/bin/bash |
| | nohup google-chrome \\ |
| | --user-data-dir="$PROFILE_DIR" \\ |
| | --load-extension="$EXTENSION_DIR" \\ |
| | --disable-extensions-except="$EXTENSION_DIR" \\ |
| | --no-first-run \\ |
| | --no-default-browser-check \\ |
| | --disable-default-apps \\ |
| | --disable-popup-blocking \\ |
| | --disable-translate \\ |
| | --disable-sync \\ |
| | --no-service-autorun \\ |
| | --simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT' \\ |
| | --disable-component-update \\ |
| | "\$@" > /dev/null 2>&1 & |
| | EOF |
| | chmod +x "$LAUNCH_SCRIPT" |
| |
|
| | # Build a new chrome shortcut and replace the one on dock |
| | echo "Updating the shortcut on Dock" |
| | mkdir -p ~/.local/share/applications |
| | cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/ |
| | sed -i "s|/usr/bin/google-chrome-stable|$LAUNCH_SCRIPT|g" ~/.local/share/applications/google-chrome.desktop |
| | update-desktop-database ~/.local/share/applications |
| |
|
| | NEW_DESKTOP_FILE="$HOME/.local/share/applications/chrome-custom.desktop" |
| | cat > "$NEW_DESKTOP_FILE" << EOF |
| | [Desktop Entry] |
| | Version=1.0 |
| | Name=Chrome (Header Mod) |
| | Exec=/usr/bin/google-chrome-stable --user-data-dir="$PROFILE_DIR" --load-extension="$EXTENSION_DIR" --no-first-run %U |
| | Terminal=false |
| | Icon=google-chrome |
| | Type=Application |
| | Categories=Network;WebBrowser; |
| | MimeType=text/html;text/xml;application/xhtml+xml; |
| | StartupWMClass=google-chrome |
| | EOF |
| | chmod +x "$NEW_DESKTOP_FILE" |
| |
|
| | CURRENT_FAVORITES=$(gsettings get org.gnome.shell favorite-apps) |
| |
|
| | if [[ $CURRENT_FAVORITES != *"'chrome-custom.desktop'"* ]]; then |
| | NEW_FAVORITES=$(echo $CURRENT_FAVORITES | sed "s/'google-chrome.desktop'//g" | sed "s/\[/['chrome-custom.desktop', /g" | sed "s/, ,/, /g" | sed "s/, \]/]/g") |
| | gsettings set org.gnome.shell favorite-apps "$NEW_FAVORITES" |
| | echo "✓ Updated" |
| | else |
| | echo "✓ Already the newest version" |
| | fi |
| | sleep 5 |