Page 2 of 2

Re: querySelectorAll

Posted: Thu Dec 06, 2018 8:43 am
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

Re: querySelectorAll

Posted: Thu Dec 06, 2018 10:11 pm
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?

Re: querySelectorAll

Posted: Fri Dec 07, 2018 7:58 am
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.