JAVASCRIPT, script required to auto detect and click next page button/links

Job ID: 32527706

Budget: $10 – $70 USD

We need a script written in pure JavaScript that does this.

1- When I visit a page that have pagination.
2- The script automatically detects the pattern and clicks next page button/link.
3- It auto clicks the next button, until it reaches last page.

OR

1- When I visit a page that have pagination.
2- I click the next page button/click first time manually. The script gets xpath/id.
3- The script automatically detects the pattern and clicks next page button/link.
4- It auto clicks the next button, until it reaches last page.

I have seen this in WebHarvy.

We can accept chrome extension scripts for this as well.

Thanks