Skip to content

Instantly share code, notes, and snippets.

@mmb
Created September 11, 2009 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmb/185072 to your computer and use it in GitHub Desktop.
Save mmb/185072 to your computer and use it in GitHub Desktop.
mozrepl function to select the next tab with title matching a regex
// mozrepl function to select the next tab with title matching a regex
function next_tab(title_re) {
var tabContainer = window.getBrowser().tabContainer;
var tabs = tabContainer.childNodes;
var numTabs = tabs.length;
var startIndex = tabContainer.selectedIndex;
var testIndex;
for (i = 0; i < numTabs - 1; i++) {
testIndex = (startIndex + i + 1) % numTabs;
if (tabs[testIndex].label.match(title_re)) {
tabContainer.selectedItem = tabs[testIndex];
break;
}
}
}
next_tab(/Google Reader/)
repl.quit()
// cat next_tab.js | nc localhost 4242
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment