function getOpenTabsCount(callback) {
  var queryInfo = {
    currentWindow: true
  };

  chrome.tabs.query(queryInfo, function (tabs) {
    callback(tabs.length.toString());
  });
}

function setBadgeWithTabCount() {
  getOpenTabsCount(function (tabs) {
    chrome.browserAction.setBadgeText({text: tabs});
  });
}

chrome.tabs.onCreated.addListener(function () {
  setBadgeWithTabCount();
});

chrome.tabs.onRemoved.addListener(function () {
  setBadgeWithTabCount();
});

chrome.tabs.onAttached.addListener(function () {
  setBadgeWithTabCount();
});

chrome.tabs.onDetached.addListener(function () {
  setBadgeWithTabCount();
});

@@ -344,32 +344,16 @@
 istener(
-function () %7B%0A  
 setBadge
@@ -360,33 +360,27 @@
 WithTabCount
-(
 );%0A
-%7D);%0A%0A
 chrome.tabs.
@@ -401,32 +401,16 @@
 istener(
-function () %7B%0A  
 setBadge
@@ -417,33 +417,27 @@
 WithTabCount
-(
 );%0A
-%7D);%0A%0A
 chrome.tabs.
@@ -459,32 +459,16 @@
 istener(
-function () %7B%0A  
 setBadge
@@ -483,17 +483,11 @@
 ount
-(
 );%0A
-%7D);%0A%0A
 chro
@@ -521,24 +521,8 @@
 ner(
-function () %7B%0A  
 setB
@@ -541,12 +541,7 @@
 ount
-();%0A%7D
 );%0A

Make listeners more concise