Skip to content

Instantly share code, notes, and snippets.

@NickLaMuro NickLaMuro/README.md Secret
Last active Nov 20, 2019

Embed
What would you like to do?
depressing_tab_count

depressing_tab_count Web Extension

A simple chrome extension that lets you know how many tabs you have open... you probably won't be pleased...

Also counts how many windows you have open, because it can.

Usage

Get the code. Either:

  • Download this gist as a zip and unpack it
  • Grab the tab_count.html, tab_count.js, and manifest.json files and put them in their own dir

Chrome

  1. Open up chrome://extensions in your browser
  2. Make sure Developer Mode is enabled
  3. Click Load unpacked extension... and point it to a directory where the code you downloaded lives.
  4. Click the button that has the puzzle piece on it (I was too lazy to make a better icon)
  5. Cry 😭

Firefox

  1. Open the directory with the downloaded code from above in a terminal
  2. Zip the contents up: $ zip -r -FS ../depressing_tab_count.zip *
  3. Open up about:debugging in your browser
  4. Click Load Temporary Add-on... and point it to the zip you just created.
  5. Click the button that has the puzzle piece on it (still too lazy to make a better icon)
  6. Weep 😭
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"name": "Tab Count",
"description": "",
"version": "2.0",
"permissions": [
"tabs"
],
"browser_action": {
"default_title": "Count the number of tabs you have open",
"default_popup": "tab_count.html"
},
"icons": {
"48": "icon.svg",
"96": "icon.svg"
},
"manifest_version": 2
}
<html>
<head>
<title>Tab Count</title>
<style>
html { font-family: Helvetica, Arial, sans-serif; font-size: 16px; }
body { background-color: #333; color: #ccc; width: 250px; }
p { margin: 5px; padding: 0px; }
</style>
</head>
<body>
<p id='windows'></p>
<p id='tabs'></p>
<script src="tab_count.js"></script>
</body>
</html>
var window_count = 0
var depressing_tab_count = 0
chrome.windows.getAll({ populate: true } ,function(windows){
windows.forEach(function(window){
window_count += 1
depressing_tab_count += window.tabs.length
})
document.getElementById('windows').innerHTML = "You have " + window_count + " windows open!";
document.getElementById('tabs').innerHTML = "You have " + depressing_tab_count + " tabs open!";
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.