Checking if a particular tab is open and closing it

DBG

New Member
VIP
Joined
Mar 2, 2021
Messages
7
Reaction score
0
Achievement
Hello,

I have a script that opens several random links from a given page in several tabs.
Say one of them is opened with a facebook page, which I don't want.
Since the opening of links is random and the link is in the page, I cannot stop the macro from opening it every now and then.
So I figured I could at least close it right away, like this:

await ClickRandomlLink ();
await Delay(Random(2500,3000));
await WaitForLoading();
var tabcheck = TabFocus("facebook.com");
if (tabcheck) {
TabFocus("facebook.com");
await ExecuteScript("window.close()");
}

Of course, it doesn't work ;) tabcheck's value is always "true" no matter wheter the facebook page is in a tab or not.
Any ideas as to how I could get it to work?

Thanks in advance!
 

opsfafsme

Well-Known Member
Rule The Universe
VIP
Joined
Jul 2, 2018
Messages
209
Reaction score
77
Website
OnlinePiercingShop.com
Achievement
Any ideas as to how I could get it to work?
the idea is simple, to view all open tabs sequentially, determine the url open in this tab

if ( await EvaluateScript("window.location.href.includes('facebook.com')") )

and close it if the url is not desirable
 

DBG

New Member
VIP
Joined
Mar 2, 2021
Messages
7
Reaction score
0
Achievement
Works beautifully. Thanks a lot!!
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu