Skip to content

Instantly share code, notes, and snippets.

@jcottrell
Last active October 7, 2025 14:08
Show Gist options
  • Select an option

  • Save jcottrell/074b59e37fb6baf53d866695a97cf624 to your computer and use it in GitHub Desktop.

Select an option

Save jcottrell/074b59e37fb6baf53d866695a97cf624 to your computer and use it in GitHub Desktop.
Count browser tabs that match a regular expression
// 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