anchorbrowser
Version:
The official TypeScript library for the Anchorbrowser API
27 lines • 1.31 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAiServiceWorker = exports.getAgentWsUrl = exports.getCdpUrl = exports.getPlaywrightChromiumFromCdpUrl = void 0;
const playwright_1 = require("playwright");
const getPlaywrightChromiumFromCdpUrl = async (apiBaseURL, sessionId, apiKey) => {
return await playwright_1.chromium.connectOverCDP((0, exports.getCdpUrl)(apiBaseURL, sessionId, apiKey));
};
exports.getPlaywrightChromiumFromCdpUrl = getPlaywrightChromiumFromCdpUrl;
const getCdpUrl = (apiBaseURL, sessionId, apiKey) => {
return `${apiBaseURL
.replace('https://', 'wss://')
.replace('http://', 'ws://')
.replace('api.', 'connect.')}?apiKey=${apiKey}&sessionId=${sessionId}`;
};
exports.getCdpUrl = getCdpUrl;
const getAgentWsUrl = (apiBaseURL, sessionId) => {
return `${apiBaseURL.replace('https://', 'wss://').replace('http://', 'ws://')}/ws?sessionId=${sessionId}`;
};
exports.getAgentWsUrl = getAgentWsUrl;
const getAiServiceWorker = (browserContext) => {
const ai = browserContext
.serviceWorkers()
.find((sw) => sw.url().includes('chrome-extension://bppehibnhionalpjigdjdilknbljaeai/background.js'));
return ai;
};
exports.getAiServiceWorker = getAiServiceWorker;
//# sourceMappingURL=browser.js.map
;