Skip to content

Instantly share code, notes, and snippets.

@nateberkopec
Last active December 3, 2018 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nateberkopec/dd481a2928ffe4d7fc5b5fbf8e13fb76 to your computer and use it in GitHub Desktop.
Save nateberkopec/dd481a2928ffe4d7fc5b5fbf8e13fb76 to your computer and use it in GitHub Desktop.
Hide gmail inbox when empty, v0.1
// ==UserScript==
// @name Gmail Inbox Empty Reward
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Hides much of the Gmail UI when your inbox is empty, to give you a little reward for reaching Inbox Zero!
// @author Nate Berkopec
// @include http://mail.google.com/*
// @include https://mail.google.com/*
// @include http://*.mail.google.com/*
// @include https://*.mail.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function hideOrDisplayInbox() {
var inbox = document.querySelector('.nH.bkK.nn');
if (inbox && inInboxView() && isInboxEmpty()) {
hideInbox(inbox);
} else {
showInbox(inbox);
};
};
function hideInbox(inbox) {
inbox.style.transition = 'opacity 2s';
inbox.style.opacity = '0';
};
function showInbox(inbox) {
inbox.style.opacity = '1';
};
function inInboxView() {
return !!document.querySelector(".aim.ain [data-tooltip~='Inbox']"); // this is the inbox icon, we're asking if its highlighted or not
};
function isInboxEmpty() {
return !document.querySelector(".aE3 .Cp tbody tr"); // rows inside your inbox
};
window.onload = function () { window.setInterval(hideOrDisplayInbox, 500) };
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment