Looking for somebody who is really good at JS and VB6

Job ID: 36312407

Budget: €8 – €50 EUR

Hello!

I am using the following VB6 browser:
https://www.vbforums.com/showthread.php?889202-VB6-WebView2-Binding-(Edge-Chromium)/page8

I have posted a question there, and this is the reply that I got and why I am now looking for somebody who can do it:

I'd ask the developer who has programmed the C# interaction (with CEF),
to write a similar js-function for you...

WebView2 is using chromium as well, but as said, the DOM-interfaces are not exposed to the VB/COM-side here.
Therefore you have to use "preloaded js-functions" to interact with the Browser-DOM "on the inside" of WV2 -
and communicate with the outside via JSON-strings.

Such a C#->js-v8 porting should not be that hard for the developer, who originally wrote the C#-stuff.

All I can do here from my end, is to show you the "principle".
Code:
Option Explicit

Private WithEvents WV As cWebView2, Elements As cCollection

Private Sub Form_Load()
Visible = True
Set WV = New_c.WebView2(hWnd)

With New_c.StringBuilder 'js-helpers
.AddNL "function getElements(sExpr){"
.AddNL " var resArr = []"
.AddNL " for (var e of document.querySelectorAll(sExpr).values()){"
.AddNL " resArr.push({tag:e.tagName, id:e.id, val:e.value, name:e.name, href:e.href})"
.AddNL " }"
.AddNL " return JSON.stringify(resArr)"
.AddNL "}"

.AddNL "function setElementBackgroundById(id, color){"
.AddNL " document.querySelector('#'+id).style.background = color"
.AddNL "}"

WV.AddScriptToExecuteOnDocumentCreated .ToString
End With

With New_c.StringBuilder 'two anchors and two buttons as test-HTML-content
.AddNL "<a id='a1' href='#foo'>LinkFoo</a><br>"
.AddNL "<input id='b1' type='button' value='button 1'><br>"
.AddNL "<a id='a2' href='#bar'>LinkBar</a><br>"
.AddNL "<input id='b2' type='button' value='button 2'><br>"

WV.NavigateToString .ToString
End With

'retrieve a few elements "by selector-expression"
Set Elements = New_c.JSONDecodeToCollection(WV.jsRun("getElements", "a, input"))

Dim Elmt As cCollection 'the enumerated Elements themselves are (again) of type cCollection - but hold a JSON-Object instead of a JSON-array
For Each Elmt In Elements 'iteration over the gathered Element-Objects in the JSON-Array: Elements
Debug.Print Elmt.SerializeToJSONString 'just to show, which properties are contained "per element"

Select Case UCase$(Elmt("tag")) 'first Property-access on an Element (here the "tag"-Property)
Case "A": WV.jsRun "setElementBackgroundById", Elmt("id"), "#f00"
Case "INPUT": WV.jsRun "setElementBackgroundById", Elmt("id"), "#0f0"
End Select
Next
End Sub
... but the adaption of the above shown principle (to your concrete problem), really is your part.
Related categories: JavaScript Visual Basic