Javascript monitor breaks if URL changes

Is it possible to monitor the contents of a secondary page from a link on the source page?

I am using javascript to click a link on the source page, waiting for the second page to load, and then trying to read contents of the second page, but it does not seem to work.

Here is a simple public example for ebay.com where I want to query information on the page linked from the ‘sell’ button.

function wait() {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve();
    }, 2000)
  });
}
async function msg() {
  document.querySelector('a[href*="sell"]').click()  // this line breaks the monitor
  await wait()
  
  insertDiv = document.createElement('div')
  insertDiv.innerHTML = document.URL  
  document.body.append(insertDiv)
  sendResponse("", insertDiv)
}
msg();

My actual use case is a bit more complicated. My source page’s link is not query-able (It is not a simple anchor tag with a url. Which means I cannot fetch the address and run a ajax request. The address is only created dynamically onclick.).

Additionally, I don’t think the page I am interested in is actually requesting a new ‘doc/page’. I think it is simply manipulating the current page and modifying the window.history. In either case I can’t get distill to query any data after clicking a link on the source page.

@evolut1010 JS selector runs in a webpage’s context. It will work if the page does not reload or redirects to another webpage. So, in your case, the JS selector will not help.

You can try out Macros to click on the link and wait for the second page to reload. Then you can add this Macro to a new monitor for making selections from the second page.

Here is the help article link: Macro: Record and Replay Automated Actions – Distill