mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
24 lines
535 B
JavaScript
24 lines
535 B
JavaScript
|
/**
|
||
|
* @license
|
||
|
* Copyright 2024 Google Inc.
|
||
|
* SPDX-License-Identifier: Apache-2.0
|
||
|
*/
|
||
|
|
||
|
// TODO: can rollup find the browser entrypoint?
|
||
|
|
||
|
import puppeteer from 'puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js';
|
||
|
|
||
|
async function onConnectClick() {
|
||
|
const wsUrl = document.querySelector('#ws').value;
|
||
|
|
||
|
const browser = await puppeteer.connect({
|
||
|
browserWSEndpoint: wsUrl,
|
||
|
});
|
||
|
|
||
|
alert('Browser has ' + (await browser.pages()).length + ' pages');
|
||
|
|
||
|
browser.disconnect();
|
||
|
}
|
||
|
|
||
|
globalThis.onConnectClick = onConnectClick;
|