Question

I Have a chrome extension, it click a button when the page is loaded.

$(document).ready(function(){
      document.querySelectorAll("input[type='submit']")[0].click(); 
});

This works, the only problem is that the button is also on the next page. So it keeps pressing the button and the page keeps reloading, so it's in a loop.

How do I fix this?

Était-ce utile?

La solution

One solution would be to refine your selector. Find an unique parent element for the page you're targeting and create a more specific selector.

Another solution would be to check the current page url or the referrer and see if it matches a certain pattern.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top