I am trying to automate navigation through search results. For instance, amazon's search results page like this one (purposely small).
I can't find many posts on the topic, and most of what is out there like this one mention handling events such as window's popstate
, hashchange
. But they will not fire.
Code snippet:
window.addEventListener('popstate', () => console.log('pop state changed'))
window.addEventListener('hashchange', () => console.log('hash changed'))
document.location.assign('/s?k=comic+books&i=digital-text&rh=n%3A156104011%2Cp_n_feature_thirty-three_browse-bin%3A18116648011&dc&page=2&qid=1588508957&rnid=18116644011&swrs=A812F8AB9BA7A775DB9E4C23ADDCD5B3&ref=sr_pg_1')
//tried ...location = '...' as well
Tried document.onload
as well... to no avail. Seems like the window
object is reset when document.location
changes (properties I attach to the windows object are lost after document.location
changes)
I want to automatically start executing some code after I manually navigate to the next results page. How do I accomplish that ?