Last active
October 7, 2025 14:08
-
-
Save jcottrell/074b59e37fb6baf53d866695a97cf624 to your computer and use it in GitHub Desktop.
Count browser tabs that match a regular expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // firefox ctrl+shift+j to open Browser (not web!) console | |
| // I needed something to count the number of open browser tabs needing code review | |
| // chatgpt helped figure out how to access the tab urls | |
| function getBrowserTabCount(regexp) { | |
| let count = 0 | |
| for (let win of Services.wm.getEnumerator('navigator:browser')) { | |
| for (let tab of win.gBrowser.tabs) { | |
| let url = tab.linkedBrowser.currentURI.spec; | |
| if (regexp.test(url)) { | |
| count += 1 | |
| } | |
| } | |
| } | |
| return count | |
| } | |
| console.log("Matching tabs:", getBrowserTabCount(/bitbucket.org\/.*?\/.*?\/commits/)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment