I'm currently coding a bot to do something for me and currently it has to open a large number of tabs every iteration and to make the bot fully automatic I have to find a way to close them all except the original the bot is running from. (The tabs have to be closed before the next iteration or what it's doing fails.)
I found a way to actually do this using a function that would detect the URL and do a specific function for that and then close it. Here's the code...
if (window.location.href.indexOf("https://www.google.com") != -1) {
So this detects that my URL contains a certain string and therefore activates on all pages after this URL. It works for what I want.