Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

querySelectorAll

User avatar
salvadordf
Posts: 4067
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: querySelectorAll

Post by salvadordf »

You can create a button, use the onclick event and call Chromium.ExecuteJavaScript with the same parameters that you see in TJSRTTIExtensionFrm.Chromium1ContextMenuCommand
Laertes
Posts: 29
Joined: Fri Apr 27, 2018 1:27 pm

Re: querySelectorAll

Post by Laertes »

Code: Select all

   //School
   chromium1.Browser.MainFrame.ExecuteJavaScript('var testhtml = document.querySelectorAll(' + quotedstr('button.pv-top-card-v2-section__link.pv-top-card-v2-section__link-education 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);

   //email
   chromium1.Browser.MainFrame.ExecuteJavaScript('var testhtml = document.querySelectorAll(' + quotedstr('section.pv-contact-info__contact-type.ci-email a.pv-contact-info__contact-link') + ')[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);

   //Company
   chromium1.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);
salvadordf wrote: Thu Dec 06, 2018 8:43 am You can create a button, use the onclick event and call Chromium.ExecuteJavaScript with the same parameters that you see in TJSRTTIExtensionFrm.Chromium1ContextMenuCommand

Code: Select all

procedure TJSRTTIExtensionFrm.ShowTextViewerMsg(var aMessage : TMessage);
begin
  // This form will show the HTML received from JavaScript
  {SimpleTextViewerFrm.Memo1.Lines.Text := FText;
  SimpleTextViewerFrm.ShowModal;}
  edit2.Text:= School;
  edit3.Text:= Company;
  edit4.Text:= Email;

end;

Code: Select all

  protected
    School: string;
    Empresa : string;
    Email : string;
But unsuccessfully, how could I extract more fields?
User avatar
salvadordf
Posts: 4067
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: querySelectorAll

Post by salvadordf »

Try using different message names and modify the TJSRTTIExtensionFrm.Chromium1ProcessMessageReceived procedure to handle them.
If that fails, try executing the JavaScript functions one after the other, not all at the same time.
Post Reply