The PureBasic WebGadget Framework currently integrates 10 Chrome DevTools Protocol (CDP) domains, encompassing a total of 84 commands. While only a subset of the full protocol is implemented, developers can still invoke any domain or method by using an alternative procedure call:
Cr_WebSocket_Command(Connection, EventID, Method.s, Params.s = #Null$)
Each command requires an Event ID, Method, and Parameters:
Commands for interacting with browser-level features such as permissions, windows, and downloads.
Browser_Close(Connection, EventID)
Browser_GetVersion(Connection, EventID)
Browser_GetBrowserCommandLine(Connection, EventID)
Browser_GetWindowBounds(Connection, EventID, WindowId)
Browser_GetWindowForTarget(Connection, EventID, TargetId.s)
Browser_GrantPermissions(Connection, EventID, Permissions.s)
Browser_ResetPermissions(Connection, EventID)
Browser_SetDownloadBehavior(Connection, EventID, Behavior.s)
Browser_SetPermission(Connection, EventID, Permission.s, Setting.s)
Browser_SetWindowBounds(Connection, EventID, WindowId, Bounds.s)
Access and manipulate the document structure of a webpage.
DOM_DescribeNode(Connection, EventID)
DOM_Disable(Connection, EventID)
DOM_Enable(Connection, EventID)
DOM_GetDocument(Connection, EventID)
DOM_GetNodeForLocation(Connection, EventID, X, Y)
DOM_GetOuterHTML(Connection, EventID)
Simulate device and environmental conditions such as screen size and geolocation.
Emulation_ClearDeviceMetricsOverride(Connection, EventID)
Emulation_ClearGeolocationOverride(Connection, EventID)
Emulation_SetDeviceMetricsOverride(Connection, EventID, W, H, DeviceScaleFactor.f, Mobile)
Emulation_SetGeolocationOverride(Connection, EventID, Latitude.f, Longitude.f, Accuracy.f)
Manage network requests, authentication challenges, and response handling.
Fetch_ContinueRequest(Connection, EventID, RequestId.s)
Fetch_ContinueWithAuth(Connection, EventID, RequestId.s, AuthChallengeResponse.s)
Fetch_Disable(Connection, EventID)
Fetch_Enable(Connection, EventID)
Fetch_FailRequest(Connection, EventID, RequestId.s, ErrorReason.s)
Fetch_FulfillRequest(Connection, EventID, RequestId.s, ResponseCode)
Fetch_GetResponseBody(Connection, EventID, RequestId.s)
Simulate user input such as keyboard events, mouse interactions, and text entry.
Input_DispatchKeyEvent(Connection, EventID)
Input_DispatchMouseEvent(Connection, EventID, Type.s, X.f, Y.f)
Input_EmulateTouchFromMouseEvent(Connection, EventID, Type.s, X.f, Y.f, Button.s)
Input_InsertText(Connection, EventID, Text.s)
Control caching, cookies, headers, and user-agent behavior.
Network_ClearBrowserCache(Connection, EventID)
Network_ClearBrowserCookies(Connection, EventID)
Network_Disable(Connection, EventID)
Network_Enable(Connection, EventID)
Network_GetCookies(Connection, EventID)
Network_GetResponseBody(Connection, EventID, RequestId.s)
Network_SetCookie(Connection, EventID, Name.s, Value.s)
Network_SetCookies(Connection, EventID, Cookies.s)
Network_SetExtraHTTPHeaders(Connection, EventID, Headers.s)
Network_SetUserAgentOverride(Connection, EventID, UserAgent.s)
Highlight, display, or hide elements on a web page for debugging and visual inspection.
Overlay_Disable(Connection, EventID)
Overlay_Enable(Connection, EventID)
Overlay_HideHighlight(Connection, EventID)
Overlay_HighlightNode(Connection, EventID, HighlightConfig.s)
Comprehensive commands for page lifecycle, rendering, navigation, and scripting operations.
Page_AddScriptToEvaluateOnNewDocument(Connection, EventID, Source.s)
Page_BringToFront(Connection, EventID)
Page_CaptureScreenshot(Connection, EventID)
Page_Close(Connection, EventID)
Page_CreateIsolatedWorld(Connection, EventID, FrameId.s)
Page_Enable(Connection, EventID)
Page_GetLayoutMetrics(Connection, EventID)
Page_GetNavigationHistory(Connection, EventID)
Page_HandleJavaScriptDialog(Connection, EventID, Accept)
Page_NavigateToHistoryEntry(Connection, EventID, EntryId.s)
Page_Navigate(Connection, EventID, URL.s)
Page_PrintToPDF(Connection, EventID)
Page_Reload(Connection, EventID)
Page_RemoveScriptToEvaluateOnNewDocument(Connection, EventID)
Page_ResetNavigationHistory(Connection, EventID)
Page_ScreencastFrameAck(Connection, EventID, SessionId)
Page_SetBypassCSP(Connection, EventID, Enabled)
Page_SetDocumentContent(Connection, EventID, FrameId.s, HTML.s)
Page_SetInterceptFileChooserDialog(Connection, EventID, Enabled)
Page_StartScreencast(Connection, EventID)
Page_StopLoading(Connection, EventID)
Page_StopScreencast(Connection, EventID)
Execute and manage JavaScript code, bindings, and scripts within the target environment.
Runtime_AddBinding(Connection, EventID, Name.s)
Runtime_AwaitPromise(Connection, EventID, PromiseObjectId.s)
Runtime_CallFunctionOn(Connection, EventID, FunctionDeclaration.s)
Runtime_CompileScript(Connection, EventID, Expression.s, SourceURL.s, PersistScript)
Runtime_Disable(Connection, EventID)
Runtime_Enable(Connection, EventID)
Runtime_Evaluate(Connection, EventID, Expression.s)
Runtime_RemoveBinding(Connection, EventID, Name.s)
Runtime_RunScript(Connection, EventID, ScriptId.s)
Attach to, manage, or control different browser targets such as tabs or extensions.
Target_ActivateTarget(Connection, EventID, TargetID.s)
Target_AttachToTarget(Connection, EventID, TargetID.s)
Target_CloseTarget(Connection, EventID, TargetID.s)
Target_CreateTarget(Connection, EventID, URL.s)
Target_DetachFromTarget(Connection, EventID)
Target_GetTargetInfo(Connection, EventID, TargetID.s)
Target_GetTargets(Connection, EventID)
Target_SetDiscoverTargets(Connection, EventID, Discover)
Executing a command from a specific domain include file is generally simpler than using the
Cr_WebSocket_Command() procedure directly. Each command mirrors the method name,
with the domain and command separated by an underscore.
List in PureBasic.Without Optional Parameters:
Page_CaptureScreenshot(Connection, #UE_Page_CaptureScreenshot)
With Optional Parameters:
NewList params_data.PARAMS_DATA()
AddElement(params_data())
params_data()\Name = "clip"
params_data()\Type = #CrWS_Object
params_data()\Input = "{" +
#DQUOTE$ + "x" + #DQUOTE$ + ":0," +
#DQUOTE$ + "y" + #DQUOTE$ + ":0," +
#DQUOTE$ + "width" + #DQUOTE$ + ":" + Str(Width) + "," +
#DQUOTE$ + "height" + #DQUOTE$ + ":" + Str(Height) + "," +
#DQUOTE$ + "scale" + #DQUOTE$ + ":" + StrF(Scale, 2) +
"}"
AddElement(params_data())
params_data()\Name = "captureBeyondViewport"
params_data()\Type = #CrWS_Boolean
params_data()\Input = "true"
Page_CaptureScreenshot(Connection, #UE_Page_CaptureScreenshot, params_data())