channel-worker 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/nst-manager.js +22 -14
- package/package.json +1 -1
package/lib/nst-manager.js
CHANGED
|
@@ -20,10 +20,17 @@ class NstManager {
|
|
|
20
20
|
// Get all running browsers
|
|
21
21
|
async getRunningBrowsers() {
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const rawRes = await fetch(`${this.baseUrl}/browsers/running`, {
|
|
24
|
+
headers: { 'x-api-key': this.apiKey },
|
|
25
|
+
});
|
|
26
|
+
const text = await rawRes.text();
|
|
27
|
+
try {
|
|
28
|
+
const data = JSON.parse(text);
|
|
29
|
+
return data?.data || [];
|
|
30
|
+
} catch {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
27
34
|
return [];
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -112,17 +119,18 @@ class NstManager {
|
|
|
112
119
|
return { profileId, alreadyRunning: true };
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
// Update language to en-US
|
|
122
|
+
// Update profile language to en-US before launch
|
|
116
123
|
try {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
124
|
+
for (const method of ['PATCH', 'PUT']) {
|
|
125
|
+
const res = await fetch(`${this.baseUrl}/profiles/${profileId}`, {
|
|
126
|
+
method,
|
|
127
|
+
headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
|
|
128
|
+
body: JSON.stringify({ fingerprint: { language: 'en-US' } }),
|
|
129
|
+
});
|
|
130
|
+
if (res.ok) { console.log(`[nst] Profile language set to en-US (${method})`); break; }
|
|
131
|
+
}
|
|
132
|
+
} catch {}
|
|
133
|
+
// Also set via connect args as fallback
|
|
126
134
|
|
|
127
135
|
// Set proxy before launch
|
|
128
136
|
if (options.proxy) {
|