Page 1 of 2
querySelectorAll
Posted: Wed Nov 28, 2018 9:53 pm
by Laertes
Hello !
Is it possible to create a variable to extract the content in this way?
document.querySelectorAll('button.pv-top-card-v2-section__link.pv-top-card-v2-section__link-experience span.pv-top-card-v2-section__entity-name')[0].innerText
"TTarga - Carreira e Recolocação"
Re: querySelectorAll
Posted: Thu Nov 29, 2018 9:54 am
by salvadordf
The querySelectorAll method is supported by Chromium.
Use a JavaScript extension like the one in the JSRTTIExtension demo to get the result in Delphi.
Re: querySelectorAll
Posted: Mon Dec 03, 2018 10:13 pm
by Laertes
Hello!
Sorry, but I can not.
Could you write a sample application code?
Thank you!

Re: querySelectorAll
Posted: Tue Dec 04, 2018 7:28 am
by salvadordf
You only need to modify the TJSRTTIExtensionFrm.Chromium1ContextMenuCommand procedure.
Replace the line 226 and set testhtml with the querySelectorAll return value.
Re: querySelectorAll
Posted: Tue Dec 04, 2018 9:41 pm
by Laertes
Hello !
I did not make it.
Let's say I want to extract the information from this field from the site
"button.pv-top-card-v2-section__link.pv-top-card-v2-section__link-experience span.pv-top-card-v2-section__entity-name"
Should I report this field somewhere?
Thank you very much for your attention.
Re: querySelectorAll
Posted: Wed Dec 05, 2018 11:20 am
by salvadordf
The TJSRTTIExtensionFrm.Chromium1ContextMenuCommand procedure would have this code when commandId is MINIBROWSER_CONTEXTMENU_JSVISITDOM :
Code: Select all
MINIBROWSER_CONTEXTMENU_JSVISITDOM :
if (browser <> nil) and (browser.MainFrame <> nil) then
browser.MainFrame.ExecuteJavaScript(
'var testhtml = document.querySelectorAll(' + quotedstr('button.pv-top-card-v2-section__link.pv-top-card-v2-section__link-experience span.pv-top-card-v2-section__entity-name') + ')[0].innerText;' +
'myextension.sendresulttobrowser(testhtml, ' + quotedstr(CUSTOMNAME_MESSAGE_NAME) + ');', // This is the call from JavaScript to the extension with DELPHI code in uTestExtension.pas
'about:blank', 0);
Notice that I replaced this line in the original code :
Code: Select all
'var testhtml = document.body.innerHTML;' +
Re: querySelectorAll
Posted: Wed Dec 05, 2018 1:42 pm
by Laertes
Hello !
Thank you very much, it worked out with the right mouse button.
How could I pass the result straight to an edit?
Re: querySelectorAll
Posted: Wed Dec 05, 2018 8:36 pm
by salvadordf
The TJSRTTIExtensionFrm.Chromium1ProcessMessageReceived procedure saves the text in FText and sends a MINIBROWSER_SHOWTEXTVIEWER message to the form.
TJSRTTIExtensionFrm.ShowTextViewerMsg is executed when the form receives the MINIBROWSER_SHOWTEXTVIEWER message. You only need to set MyEdit.Text := FText; and remove the SimpleTextViewerFrm references from that procedure.
Re: querySelectorAll
Posted: Wed Dec 05, 2018 8:55 pm
by Laertes
salvadordf wrote: Wed Dec 05, 2018 8:36 pm
The TJSRTTIExtensionFrm.Chromium1ProcessMessageReceived procedure saves the text in FText and sends a MINIBROWSER_SHOWTEXTVIEWER message to the form.
TJSRTTIExtensionFrm.ShowTextViewerMsg is executed when the form receives the MINIBROWSER_SHOWTEXTVIEWER message. You only need to set MyEdit.Text := FText; and remove the SimpleTextViewerFrm references from that procedure.
Butto1.onclik.....
Edit1.text:= FText;
Re: querySelectorAll
Posted: Thu Dec 06, 2018 2:01 am
by Laertes
Sorry, but how do you get this result without having to right-click?
I would like to click the button and display the result in the edit. According to the image.
