Skip to content

Instantly share code, notes, and snippets.

@erikvold
Forked from zpao/run-this.js
Created June 10, 2011 23:59
Show Gist options
  • Save erikvold/1020051 to your computer and use it in GitHub Desktop.
Save erikvold/1020051 to your computer and use it in GitHub Desktop.
Simple Window + Tab Stats
// Run this in your error console
var wc=0, tc=0;
var wm = window.top.opener.Services.wm;
var e = wm.getEnumerator("navigator:browser");
var uc = { };
while (e.hasMoreElements()) {
var tabs = e.getNext().gBrowser.tabs;
wc+=1;
tc += tabs.length;
Array.forEach(tabs, function(t) {
var url = t.linkedBrowser.currentURI.spec;
if (!(url in uc)) {
uc[url] = 0;
}
uc[url]++;
});
}
var s = "Open windows: " + wc + "\nOpen tabs: " + tc + "\nDuplicated urls:\n";
for ([u,c] in Iterator(uc)) {
if (c > 1) {
s += " " + c + " - " + u + "\n";
}
}
s;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment