Created
September 11, 2009 04:22
-
-
Save mmb/185072 to your computer and use it in GitHub Desktop.
mozrepl function to select the next tab with title matching a regex
This file contains 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
// 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