Get the Number of Tabs Open in Google Chrome

Hi,
I'm trying to get a macro repeated a number of times. I typically open several tabs (could be 10s) and want a macro run on each tab. So, what I was hoping to do is create a variable and name it a NoTabs and set it to the number of opened tabs. Then have another variable and name it Counter and set it to 1. As long the Counter is less NoTabs, the macro will copy the URL of the Tab, the close it. Then repeat till the Counter equals the NoTabs, then the macro will quit.
I'm struggling to find out how to create a variable that will be set to the number of open tabs. Any help would be greatly appreciated.

Try this AppleScript:

tell application "Google Chrome" to count every tab of front window

in an Execute AppleScript action that saves the results to the NoTabs variable:

Hi

I found an AppleScript which will return all the urls and titles open in Chrome.


Maybe this is a better approach.

Afterwards you could use Keyboard Maestro to close the current window in Chrome.

Easily done, no AppleScript required.

Keyboard Maestro Actions.kmactions (1.2 KB)

2 Likes

What do you want to do with the URLs that you copy?

Here is a macro that will get a list of URLs of every tab of every window, store in a KM variable, and then close ALL Chrome windows. Now that you have a KM variable ("GLU__URLList") with the list of URLs what do you want to do with them?

Example Output

MACRO:   @Web Get List of URLs in All Tabs in All Windows [Example]

--- VER: 1.0    2017-09-14 ---

DOWNLOAD:

@Web Get List of URLs in All Tabs in All Windows [Example].kmmacros (3.3 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

To close ALL Chrome Windows, uncomment (remove the dashes) in this line:
` --close every window


Hey JMichaelTX
Thank you very much for all your work!! This is really wonderful. I downloaded the macro and will execute it now.
I only need the list of URLs. My intention is to copy them to a word document and keep for research and reference for a paper Iā€™m writing.
Thank you very much!!!
Alex

Hey Peternlewis,
Thank you very much. This seems very slick and very easy to follow!! Thx a million.
Alex

Hey Jimmy,
Thank you very much. This is great!!
Alex

@Alex_aa, glad you found my macro helpful.

Here's another version with these changes:

  1. Gets ONLY the tabs of the FrontMost Chrome window
  2. Get both Page Title and URL
  3. Builds a nicely formated list, ready to paste into Word
  4. Activates Word, and prompts you to paste.

Easiest way to use is position your text cursor in Word where you want the list, and trigger the macro.

Example Output


MACRO:   @Web Get List of URLs in All Tabs in FrontMost Window [Example]

ā€” VER: 2.0    2017-09-14 ā€”

DOWNLOAD:

@Web Get List of URLs in All Tabs in FrontMost Window [Example].kmmacros (6.7 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

Macro Image


Questions?