File size: 6,793 Bytes
6b083cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#!/bin/bash

# Fully Automated Header Modifier for Chrome (Ubuntu x86)
# Creates a custom Chrome extension to modify User-Agent and Sec-Ch-Ua-Platform
# No manual steps required!

set -e

PROFILE_DIR="$HOME/.config/google-chrome-headers"
EXTENSION_DIR="$PROFILE_DIR/HeaderModifier"

echo "================================================"
echo "Automated Header Modifier Setup for Chrome"
echo "================================================"
echo ""

# Install Google Chrome if not present
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

# Create extension directory
echo ""
echo "[2/3] Creating header modifier extension..."
rm -rf "$EXTENSION_DIR"
mkdir -p "$EXTENSION_DIR"

# Create manifest.json
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

# Create rules.json for declarativeNetRequest
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

# Create background.js
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