Last active
December 3, 2018 14:49
-
-
Save nateberkopec/dd481a2928ffe4d7fc5b5fbf8e13fb76 to your computer and use it in GitHub Desktop.
Hide gmail inbox when empty, v0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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