channel-worker 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/lib/nst-manager.js +17 -34
  2. package/package.json +1 -1
@@ -125,43 +125,26 @@ class NstManager {
125
125
  await this.setProxy(profileId, options.proxy);
126
126
  }
127
127
 
128
- console.log(`[nst] Starting browser for profile: ${profileId}`);
129
- const res = await this.client.browsers().startBrowser(profileId);
130
- console.log(`[nst] Browser started`);
128
+ // Use connectBrowser instead of startBrowser — allows passing --load-extension args
129
+ const connectConfig = {
130
+ headless: false,
131
+ autoClose: false,
132
+ };
131
133
 
132
- // Set nstProfileId in chrome.storage via CDP
133
- try {
134
- // Wait for browser to fully start
135
- await new Promise(r => setTimeout(r, 3000));
136
-
137
- const debugInfo = await this.client.browsers().getBrowserDebugger(profileId);
138
- const wsUrl = debugInfo?.data?.webSocketDebuggerUrl;
139
- if (wsUrl) {
140
- const WebSocket = require('ws');
141
- const ws = new WebSocket(wsUrl);
142
- await new Promise((resolve, reject) => {
143
- const timeout = setTimeout(() => { ws.close(); reject(new Error('CDP timeout')); }, 10000);
144
- ws.on('open', () => {
145
- // Navigate a new tab to set storage
146
- ws.send(JSON.stringify({
147
- id: 1,
148
- method: 'Runtime.evaluate',
149
- params: {
150
- expression: `chrome.storage && chrome.storage.local ? chrome.storage.local.set({nstProfileId: "${profileIdOrName}"}) : null`,
151
- awaitPromise: true,
152
- },
153
- }));
154
- setTimeout(() => { clearTimeout(timeout); ws.close(); resolve(); }, 2000);
155
- });
156
- ws.on('error', (e) => { clearTimeout(timeout); reject(e); });
157
- });
158
- console.log(`[nst] Profile ID "${profileIdOrName}" set in extension storage`);
159
- }
160
- } catch (e) {
161
- console.log(`[nst] Could not set profile ID in storage: ${e.message}`);
134
+ // Add extension path if provided
135
+ if (options.extensionPath) {
136
+ connectConfig.args = {
137
+ '--load-extension': options.extensionPath,
138
+ '--disable-extensions-except': options.extensionPath,
139
+ };
140
+ console.log(`[nst] Loading extension: ${options.extensionPath}`);
162
141
  }
163
142
 
164
- return { profileId, response: res };
143
+ console.log(`[nst] Connecting browser for profile: ${profileId}`);
144
+ const res = await this.client.cdpEndpoints().connectBrowser(profileId, connectConfig);
145
+ console.log(`[nst] Browser started`);
146
+
147
+ return { profileId, wsEndpoint: res?.data?.webSocketDebuggerUrl, response: res };
165
148
  }
166
149
 
167
150
  // Stop browser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {