Advertisement
MaxG

Count Chrome windows and tabs

Jun 17th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Run in console in an option window for an extension with tab privileges, IE "Too many tabs"
  2. chrome.windows.getAll({populate:true},function(windows){
  3. var t = 0;
  4. var w = 0;
  5.   windows.forEach(function(window){
  6.   w++;
  7.     window.tabs.forEach(function(tab){
  8.       //collect all of the urls here, I will just log them instead
  9.       //console.log(tab.url); // Uncomment to have each tab URL printed in the log.
  10.       t++;
  11.     });
  12.   });
  13.   console.log("Total tabs: "+t+" in "+w+" windows");
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement