1

I am opening a new tab using GM_openInTab inside my tampermonkey script, but I am not able to interact with the elements of this new tab using my code.

I simply want to click a button in the newly opened tab as soon as it opens and close it instantly.

Thanks in advance!

1 Answers1

0

You have to run your script on the URL of the new tab you are opening as well (add an additional @include on top), you could make a distinction at the beginning of the script, like this:

if (location.href == oldurl){
  //open new tab
} else if (location.href == newurl){
  //click button, close
}
CennoxX
  • 773
  • 1
  • 9
  • 20