-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Hi,
I'm intercepting the bodies of XHRs sent from my application to the user. I'm using this awesome library for this purpose.
Scenario:
- Users open the main application site in a tab.
- Users can open additional tabs (1-5) by right-clicking links to my application within that first tab.
Technical Details:
Environment: Chromium browser on Windows 11
My current solution:
// Initialization of global instances:
globalCtx = context.Background()
globalDevt = devtool.New("http://127.0.0.1:9222")
// Periodically check for new tabs:
ticker := time.NewTicker(100 * time.Millisecond)
targets, err := globalDevt.List(globalCtx)
for _, tab := range targets {
if tab.Type == "page" {
tabConnection, err := rpcc.DialContext(globalCtx, target.WebSocketDebuggerURL)
if err != nil {
// Handle error
}
tabClient := cdp.NewClient(tabConnection)
// ... (Logic for XHR interception on this tabClient)
}
}
Is there any better way to do this? I tried using gists avaialable on the web, but no luck.
I'm asking, because I have also second program connected to same chrome instance (yes, i have to have 2 programs connected to same browser using cdp :( ) and I think that this frequent querying for tabs may cause interferences I have between these 2 programs
Metadata
Metadata
Assignees
Labels
No labels