How to find page load completed

已查看 42 次
跳至第一个未读帖子

yureshwar ravuri

未读,
2021年7月14日 00:46:522021/7/14
收件人 Chromium Extensions
Hi,

We are working on an Open Source Chrome extension: Digital Assistant Client

We have a script which invokes clicks on web pages.
We record a sequence of clicks as a 'flow' or 'task'. i.e. After the first click is invoked, we wait 5 s for the page to load and then invoke the 2nd click.

setTimeout(function(){UDAPluginSDK.showhtml();}, 5000);

Now, instead of waiting for 5s, we want to explore if we can invoke the 2nd click as soon as the page is loaded. We tried using "onPageLoad" but we realised that this does not work for modern single page (responsive) applications. i.e. we don't know when the js has finished executing.

window.addEventListener('load', (event) => {
setTimeout(function (){
UDAPluginSDK.modifybodyhtml();
},2000);
});

Thanks & Regards,
Yureshwar Ravuri
Mob: +91 9030003889
Mail: yure...@gmail.com

Sergey Gorin

未读,
2021年7月14日 15:23:562021/7/14
收件人 Chromium Extensions、yure...@gmail.com
Hi, 
I would suggest make use the following manifest tags. Content script gains control when DOM is ready.

  "content_scripts": [
    {
      "run_at": "document_end",
      "all_frames": true
    }
  ],

Best regards,
Sergey Gorin

Yureshwar Ravuri

未读,
2021年7月16日 01:55:072021/7/16
收件人 Chromium Extensions、svg...@gmail.com、Yureshwar Ravuri
Hi Sergey,

Thanks for your reply. I have used the run_at already in the extension. I am talking about single page applications which has xmlhttp requests which needs to fetch the dynamic data and then render the page. How do we detect such js executions too are completed when we are navigating the user automatically.

Teddy

未读,
2021年7月16日 06:41:512021/7/16
收件人 Yureshwar Ravuri、Chromium Extensions、svg...@gmail.com
On Jul 15, 2021, at 10:55 PM -0700, Yureshwar Ravuri
<yure...@gmail.com> wrote:
>I am talking about single page applications which has xmlhttp requests
>which needs to fetch the dynamic data and then render the page. How do
>we detect such js executions too are completed when we are navigating
>the user automatically.

If the history is changing, you may be able to use an `onpopstate`
handler to detect page changes in a single-page application:

https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate

--










*"This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify the
sender immediately"*
回复全部
回复作者
转发
0 个新帖子