Skip to content

Instantly share code, notes, and snippets.

@aaronn
Last active April 11, 2019 15:24
Show Gist options
  • Save aaronn/3dd4bc8f9b70b9e0a06c to your computer and use it in GitHub Desktop.
Save aaronn/3dd4bc8f9b70b9e0a06c to your computer and use it in GitHub Desktop.

Revisions

  1. aaronn revised this gist May 22, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ TODO: Update count on item removal / read.
    */
    window.fluid.dockBadge = '';
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);
    setInterval(updateBadge, 5000);

    function updateBadge() {
    // Inbox title will always be the first item in the D4 Class. It's shown and unshown depending on the selected folder (snoozed, etc)
  2. aaronn revised this gist May 22, 2015. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -20,24 +20,24 @@ TODO: Update count on item removal / read.
    window.fluid.dockBadge = '';
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);

    function updateBadge() {
    // Inbox title will always be the first item in the D4 Class. It's shown and unshown depending on the selected folder (snoozed, etc)
    var inboxTabSpan = document.getElementsByClassName('d4')[0].getElementsByTagName('span')[0];
    var inboxTabSpan = document.getElementsByClassName('bl')[0].getElementsByTagName('span')[0];
    var inboxTabTitle = inboxTabSpan.getAttribute('title');
    var inboxTabStyle = inboxTabSpan.getAttribute('style');

    if (inboxTabStyle === 'display: none;') {
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
    //Check for Inbox Zero Sunrise Image
    //Check for Inbox Zero
    var inboxZero = document.getElementsByClassName('j');
    if (inboxZero.length >= 1) {
    window.fluid.dockBadge = '';
    } else {
    // Inbox visible
    var unreadEmails = document.getElementsByClassName('bX oD');
    var unreadEmails = document.getElementsByClassName('ss');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

    /////////////////////////////
    @@ -46,7 +46,7 @@ function updateBadge() {
    // unreadEmails.length = ONLY UNREAD ITEMS IN INBOX
    var count = unreadEmails.length;
    /////////////////////////////

    if (count >= 1) {
    window.fluid.dockBadge = count;
    } else {
  3. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ function updateBadge() {
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
    //Check for Inbox Zero
    //Check for Inbox Zero Sunrise Image
    var inboxZero = document.getElementsByClassName('j');
    if (inboxZero.length >= 1) {
    window.fluid.dockBadge = '';
  4. aaronn revised this gist Nov 21, 2014. 1 changed file with 20 additions and 15 deletions.
    35 changes: 20 additions & 15 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,6 @@ Some Caveats:
    TODO: Update count on item removal / read.
    */

    window.fluid.dockBadge = '';
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);
    @@ -32,21 +31,27 @@ function updateBadge() {
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
    // Inbox visible
    var unreadEmails = document.getElementsByClassName('bX oD');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

    /////////////////////////////
    // totalEmails.length = ALL EMAILS IN INBOX
    // OR
    // unreadEmails.length = ONLY UNREAD ITEMS IN INBOX
    var count = unreadEmails.length;
    /////////////////////////////

    if (count >= 1) {
    window.fluid.dockBadge = count;
    } else {
    //Check for Inbox Zero
    var inboxZero = document.getElementsByClassName('j');
    if (inboxZero.length >= 1) {
    window.fluid.dockBadge = '';
    } else {
    // Inbox visible
    var unreadEmails = document.getElementsByClassName('bX oD');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

    /////////////////////////////
    // totalEmails.length = ALL EMAILS IN INBOX
    // OR
    // unreadEmails.length = ONLY UNREAD ITEMS IN INBOX
    var count = unreadEmails.length;
    /////////////////////////////

    if (count >= 1) {
    window.fluid.dockBadge = count;
    } else {
    window.fluid.dockBadge = '';
    }
    }
    }
    }
  5. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ function updateBadge() {
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
    // Inbox visible.
    // Inbox visible
    var unreadEmails = document.getElementsByClassName('bX oD');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

  6. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ function updateBadge() {
    // totalEmails.length = ALL EMAILS IN INBOX
    // OR
    // unreadEmails.length = ONLY UNREAD ITEMS IN INBOX
    var count = totalEmails.length;
    var count = unreadEmails.length;
    /////////////////////////////

    if (count >= 1) {
  7. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ function updateBadge() {
    var inboxTabTitle = inboxTabSpan.getAttribute('title');
    var inboxTabStyle = inboxTabSpan.getAttribute('style');

    if (inboxTabStyle == 'display: none;') {
    if (inboxTabStyle === 'display: none;') {
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
  8. aaronn revised this gist Nov 21, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ function updateBadge() {
    var inboxTabTitle = inboxTabSpan.getAttribute('title');
    var inboxTabStyle = inboxTabSpan.getAttribute('style');

    if (inboxTabStyle == "display: none;") {
    if (inboxTabStyle == 'display: none;') {
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
    @@ -37,9 +37,9 @@ function updateBadge() {
    var totalEmails = document.getElementsByClassName('scroll-list-item');

    /////////////////////////////
    // totalEmails = ALL EMAILS IN INBOX
    // totalEmails.length = ALL EMAILS IN INBOX
    // OR
    // unreadEmails = ONLY UNREAD ITEMS IN INBOX
    // unreadEmails.length = ONLY UNREAD ITEMS IN INBOX
    var count = totalEmails.length;
    /////////////////////////////

  9. aaronn revised this gist Nov 21, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,8 @@ TODO: Update count on item removal / read.
    */

    window.fluid.dockBadge = '';
    setTimeout(updateBadge, 2500);
    setInterval(updateBadge, 5000);
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);

    function updateBadge() {
    // Inbox title will always be the first item in the D4 Class. It's shown and unshown depending on the selected folder (snoozed, etc)
  10. aaronn revised this gist Nov 21, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,8 @@ TODO: Update count on item removal / read.
    */

    window.fluid.dockBadge = '';
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);
    setTimeout(updateBadge, 2500);
    setInterval(updateBadge, 5000);

    function updateBadge() {
    // Inbox title will always be the first item in the D4 Class. It's shown and unshown depending on the selected folder (snoozed, etc)
    @@ -40,11 +40,11 @@ function updateBadge() {
    // totalEmails = ALL EMAILS IN INBOX
    // OR
    // unreadEmails = ONLY UNREAD ITEMS IN INBOX
    var count = totalEmails;
    var count = totalEmails.length;
    /////////////////////////////

    if (count >= 1) {
    window.fluid.dockBadge = count.length;
    window.fluid.dockBadge = count;
    } else {
    window.fluid.dockBadge = '';
    }
  11. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ Includes options for total badge count and unread badge count.
    Some Caveats:
    - This doesn't update the badge unless it's looking at the inbox.
    - The workaround is to only show the badge count when the inbox tab is active, otherwise it shows '?' as a reminder on other tabs (snoozed, etc).
    - No idea how well this works with more than one tab open.
    TODO: Update count on item removal / read.
    */
  12. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ Includes options for total badge count and unread badge count.
    Some Caveats:
    - This doesn't update the badge unless it's looking at the inbox.
    - The workaround is to only show the badge count when looking at the inbox, otherwise it shows '?' as a reminder.
    - The workaround is to only show the badge count when the inbox tab is active, otherwise it shows '?' as a reminder on other tabs (snoozed, etc).
    TODO: Update count on item removal / read.
    */
  13. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ function updateBadge() {
    var inboxTabStyle = inboxTabSpan.getAttribute('style');

    if (inboxTabStyle == "display: none;") {
    // Inbox hidden, don't scrape. (Kind of shitty solution, yeah.)
    // Inbox hidden.
    window.fluid.dockBadge = '?';
    } else {
    // Inbox visible.
  14. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,7 @@ Some Caveats:
    TODO: Update count on item removal / read.
    */

    window.fluid.dockBadge = '';
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);
  15. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    /* This is a FluidApp userscript for Google Inbox on the desktop.
    /* This is a FluidApp userscript for Google Inbox for Mac.
    Includes options for total badge count and unread badge count.
    1) You need the paid version of FluidApp (http://fluidapp.com/)
  16. aaronn revised this gist Nov 21, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -17,10 +17,10 @@ Some Caveats:
    TODO: Update count on item removal / read.
    */
    window.fluid.dockBadge = '';
    setTimeout(updateDockBadge, 3000);
    setInterval(updateDockBadge, 15000);
    setTimeout(updateBadge, 5000);
    setInterval(updateBadge, 10000);

    function updateDockBadge() {
    function updateBadge() {
    // Inbox title will always be the first item in the D4 Class. It's shown and unshown depending on the selected folder (snoozed, etc)
    var inboxTabSpan = document.getElementsByClassName('d4')[0].getElementsByTagName('span')[0];
    var inboxTabTitle = inboxTabSpan.getAttribute('title');
  17. aaronn revised this gist Nov 21, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -27,11 +27,10 @@ function updateDockBadge() {
    var inboxTabStyle = inboxTabSpan.getAttribute('style');

    if (inboxTabStyle == "display: none;") {
    // If the first item isn't being shown we know that inbox is hidden-- so we should reset the badge to remind the user to swap it out.
    // Kind of shitty solution, yeah.
    // Inbox hidden, don't scrape. (Kind of shitty solution, yeah.)
    window.fluid.dockBadge = '?';
    } else {
    // We know the user has the inbox visible so we can start scraping for the badge count.
    // Inbox visible.
    var unreadEmails = document.getElementsByClassName('bX oD');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

  18. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ function updateDockBadge() {
    var count = totalEmails;
    /////////////////////////////

    if (count) {
    if (count >= 1) {
    window.fluid.dockBadge = count.length;
    } else {
    window.fluid.dockBadge = '';
  19. aaronn revised this gist Nov 21, 2014. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -35,15 +35,12 @@ function updateDockBadge() {
    var unreadEmails = document.getElementsByClassName('bX oD');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

    // CUSTOMIZE HERE
    /////////////////////////////
    /////////////////////////////
    // totalEmails = ALL EMAILS IN INBOX
    // OR
    // unreadEmails = ONLY UNREAD ITEMS IN INBOX
    var count = totalEmails;
    /////////////////////////////
    /////////////////////////////

    if (count) {
    window.fluid.dockBadge = count.length;
  20. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ Includes options for total badge count and unread badge count.
    Some Caveats:
    - This doesn't update the badge unless it's looking at the inbox.
    - The workaround is to only show the badge count when looking at the inbox, otherwise it shows '?'
    - The workaround is to only show the badge count when looking at the inbox, otherwise it shows '?' as a reminder.
    TODO: Update count on item removal / read.
    */
  21. aaronn revised this gist Nov 21, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ Includes options for total badge count and unread badge count.
    4) Go to window -> userscript and add click the plus sign under the first table (on the left). Name the item 'Inbox'.
    5) In the second table (on the right) click the plus and type in "*inbox.google.com*".
    6) Paste the contents of this document into the script area below that.
    7) Configure badge count (for total or unread only in the code below).
    8) Refresh your FluidApp.
    7) Configure badge count (for total or unread only) in the code below.
    8) Refresh your FluidApp. (CMD + R)
    Some Caveats:
    - This doesn't update the badge unless it's looking at the inbox.
  22. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Includes options for total badge count and unread badge count.
    3) Set the user-agent to Chrome
    4) Go to window -> userscript and add click the plus sign under the first table (on the left). Name the item 'Inbox'.
    5) In the second table (on the right) click the plus and type in "*inbox.google.com*".
    6) Paste this document into the script area below that.
    6) Paste the contents of this document into the script area below that.
    7) Configure badge count (for total or unread only in the code below).
    8) Refresh your FluidApp.
  23. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    /* This is a FluidApp userscript for Google Inbox on the desktop.
    Includes options for total badge count and unread badge count.
    1) You need the paid version of FluidApp
    1) You need the paid version of FluidApp (http://fluidapp.com/)
    2) Point Fluid to https://inbox.google.com (I recommend the icon from here: https://medium.com/@chrismessina/create-an-icon-for-google-inbox-in-your-dock-ed269312e3bc)
    3) Set the user-agent to Chrome
    4) Go to window -> userscript and add click the plus sign under the first table (on the left). Name the item 'Inbox'.
  24. aaronn revised this gist Nov 21, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    /* This is a FluidApp userscript for Google Inbox on the desktop. Includes options for total badge count and unread badge count.
    /* This is a FluidApp userscript for Google Inbox on the desktop.
    Includes options for total badge count and unread badge count.
    1) You need the paid version of FluidApp
    2) Point Fluid to https://inbox.google.com (I recommend the icon from here: https://medium.com/@chrismessina/create-an-icon-for-google-inbox-in-your-dock-ed269312e3bc)
    3) Set the user-agent to Chrome
  25. aaronn revised this gist Nov 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    /* This is a FluidApp userscript for Google Inbox on the desktop.
    /* This is a FluidApp userscript for Google Inbox on the desktop. Includes options for total badge count and unread badge count.
    1) You need the paid version of FluidApp
    2) Point Fluid to https://inbox.google.com (I recommend the icon from here: https://medium.com/@chrismessina/create-an-icon-for-google-inbox-in-your-dock-ed269312e3bc)
    3) Set the user-agent to Chrome
  26. aaronn revised this gist Nov 21, 2014. 1 changed file with 13 additions and 3 deletions.
    16 changes: 13 additions & 3 deletions google-inbox-userscript.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,16 @@
    /* This doesn't update the badge unless it's looking at the inbox.
    The workaround is to only show the badge count when looking at the inbox, otherwise it shows a 'Go To Inbox' message.
    The idea here is it's better to show an explicitly 'bad count' than a wrong count if it's sitting in the dock for a while and you're expecting an email.
    /* This is a FluidApp userscript for Google Inbox on the desktop.
    1) You need the paid version of FluidApp
    2) Point Fluid to https://inbox.google.com (I recommend the icon from here: https://medium.com/@chrismessina/create-an-icon-for-google-inbox-in-your-dock-ed269312e3bc)
    3) Set the user-agent to Chrome
    4) Go to window -> userscript and add click the plus sign under the first table (on the left). Name the item 'Inbox'.
    5) In the second table (on the right) click the plus and type in "*inbox.google.com*".
    6) Paste this document into the script area below that.
    7) Configure badge count (for total or unread only in the code below).
    8) Refresh your FluidApp.
    Some Caveats:
    - This doesn't update the badge unless it's looking at the inbox.
    - The workaround is to only show the badge count when looking at the inbox, otherwise it shows '?'
    TODO: Update count on item removal / read.
    */
  27. aaronn renamed this gist Nov 21, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  28. aaronn created this gist Nov 21, 2014.
    42 changes: 42 additions & 0 deletions google-inbox-userscript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    /* This doesn't update the badge unless it's looking at the inbox.
    The workaround is to only show the badge count when looking at the inbox, otherwise it shows a 'Go To Inbox' message.
    The idea here is it's better to show an explicitly 'bad count' than a wrong count if it's sitting in the dock for a while and you're expecting an email.

    TODO: Update count on item removal / read.
    */
    window.fluid.dockBadge = '';
    setTimeout(updateDockBadge, 3000);
    setInterval(updateDockBadge, 15000);

    function updateDockBadge() {
    // Inbox title will always be the first item in the D4 Class. It's shown and unshown depending on the selected folder (snoozed, etc)
    var inboxTabSpan = document.getElementsByClassName('d4')[0].getElementsByTagName('span')[0];
    var inboxTabTitle = inboxTabSpan.getAttribute('title');
    var inboxTabStyle = inboxTabSpan.getAttribute('style');

    if (inboxTabStyle == "display: none;") {
    // If the first item isn't being shown we know that inbox is hidden-- so we should reset the badge to remind the user to swap it out.
    // Kind of shitty solution, yeah.
    window.fluid.dockBadge = '?';
    } else {
    // We know the user has the inbox visible so we can start scraping for the badge count.
    var unreadEmails = document.getElementsByClassName('bX oD');
    var totalEmails = document.getElementsByClassName('scroll-list-item');

    // CUSTOMIZE HERE
    /////////////////////////////
    /////////////////////////////
    // totalEmails = ALL EMAILS IN INBOX
    // OR
    // unreadEmails = ONLY UNREAD ITEMS IN INBOX
    var count = totalEmails;
    /////////////////////////////
    /////////////////////////////

    if (count) {
    window.fluid.dockBadge = count.length;
    } else {
    window.fluid.dockBadge = '';
    }
    }
    }