Close Tabs with Specifics URLS in Chrome

Pressing one key to quit all facebook.com, twitter.com, linkedin.com, etc. Chrome tabs would mean cleaning my mind. I can activate a Chrome Tab, but not ... close. Is this possible or I am crazy?

1 Like

Yes, it's possible. All you need is a simple script in an "Execute an AppleScript" action:

tell application "Google Chrome"
	tell front window
		close (every tab whose URL contains "facebook")
		close (every tab whose URL contains "twitter")
		close (every tab whose URL contains "linkedin")
	end tell
end tell
5 Likes

Oh god, wow. Next step would be to close every Google Chrome Windows ... right now, only the front windows. Is their a way?

Yep. @gglick got you 95% of the way there.
This simple mod to his AppleScript will do the trick.

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Please let us know if it meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Close All Browser Tabs With DomainName in List [Example]

-~~~ VER: 1.0    2020-08-08 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Close All Browser Tabs With DomainName in List [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


3 Likes

Hello @gglick and @JMichaelTX ,
I use your scripts a lot. thanks very much. Is it conceivable to modify the script so that instead of closing all tabs containing the name deepl (translation software), you close all except one, ideally the most recent ?
thank you !

This. Is. Wow. Wonderful.

1 Like

It may be conceivable, but not easy. To start with how would you determine which is the "most recent"?

2 Likes

If it's not simple let's drop the idea.
Most recent tab: good point.
thanks very much