Network capture helps you understand what a page loads and can reveal API endpoints behind a web interface.
// Capture Network Traffic — Monitor HTTP requests//// This script enables network capture, navigates to a page,// and inspects the HTTP requests that were made. Useful for// finding API endpoints and understanding page behavior.
// Ensure we have a browser tabawait g.tabs.newBrowserTab();
// Enable network captureg.network.enable();g.log("Network capture enabled. Navigating...");
// Navigate to trigger some requestsawait g.nav.navigateToUrl("https://example.com");
// Wait a moment for requests to be capturedawait g.wait(2000);
// Search captured trafficconst traffic = g.network.search(null, { limit: 10});
g.log("Captured " + traffic.length + " request(s):");
for (const entry of traffic) { const status = entry.responseStatusCode || "pending"; const type = entry.contentType || "unknown"; g.log(" " + entry.method + " " + status + " " + type + " — " + entry.url.substring(0, 80));}
// You can also wait for a specific request pattern// const req = await g.network.waitForRequest("*/api/*", {// timeout: 10000// });
g.log("Done! Check the History pane > Network tab for details.");