Skip to content

Instantly share code, notes, and snippets.

@NickLaMuro
Last active November 21, 2019 02:10
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save NickLaMuro/39feeb9142fc1980fbfa to your computer and use it in GitHub Desktop.
depressing_tab_count
# Build file
depressing_tab_count.zip

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 😭
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"name": "(Depressing) 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": "sob.svg",
"96": "sob.svg"
},
"manifest_version": 2
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BUILDFILE = "depressing_tab_count.zip"
LIBFILES = Rake::FileList.new %w[
*.svg
manifest.json
tab_count.*
README.md
]
require 'rake/clean'
CLEAN.include BUILDFILE
desc "Build the extension"
file BUILDFILE => LIBFILES do
sh "zip -r -FS depressing_tab_count.zip #{LIBFILES.to_a.join ' '}"
end
task :default => BUILDFILE
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<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!";
if (depressing_tab_count < 50) {
browser.browserAction.setIcon({path: "smile.svg"});
} else if (depressing_tab_count < 100) {
browser.browserAction.setIcon({path: "worried.svg"});
} else if (depressing_tab_count < 150) {
browser.browserAction.setIcon({path: "cry.svg"});
} else if (depressing_tab_count < 200) {
browser.browserAction.setIcon({path: "nauseated.svg"});
} else if (depressing_tab_count < 250) {
browser.browserAction.setIcon({path: "vomit.svg"});
} else {
browser.browserAction.setIcon({path: "sob.svg"});
}
})
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment