Skip to content

Instantly share code, notes, and snippets.

@piec
Last active September 16, 2025 13:30
Show Gist options
  • Save piec/d17ac9317025c96bb5f3a88ecab7f8e0 to your computer and use it in GitHub Desktop.
Save piec/d17ac9317025c96bb5f3a88ecab7f8e0 to your computer and use it in GitHub Desktop.

Revisions

  1. piec revised this gist Sep 16, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gmail-toggle-unread.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    // @namespace Violentmonkey Scripts
    // @match https://mail.google.com/*
    // @grant none
    // @version 1.1
    // @author -
    // @version 1.2
    // @author piec
    // @description 3/17/2025, 10:19:57 AM
    // @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
    // @homepageURL https://gist.github.com/piec/d17ac9317025c96bb5f3a88ecab7f8e0
  2. piec revised this gist Mar 17, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gmail-toggle-unread.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    // @namespace Violentmonkey Scripts
    // @match https://mail.google.com/*
    // @grant none
    // @version 1.0
    // @version 1.1
    // @author -
    // @description 3/17/2025, 10:19:57 AM
    // @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
  3. piec revised this gist Mar 17, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gmail-toggle-unread.js
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,8 @@
    // @author -
    // @description 3/17/2025, 10:19:57 AM
    // @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
    // @homepageURL https://gist.github.com/piec/d17ac9317025c96bb5f3a88ecab7f8e0
    // @downloadURL https://gist.github.com/piec/d17ac9317025c96bb5f3a88ecab7f8e0/raw/gmail-toggle-unread.js
    // @grant GM_getValue

    // ==/UserScript==
  4. piec created this gist Mar 17, 2025.
    24 changes: 24 additions & 0 deletions gmail-toggle-unread.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    // ==UserScript==
    // @name gmail - toggle is unread
    // @namespace Violentmonkey Scripts
    // @match https://mail.google.com/*
    // @grant none
    // @version 1.0
    // @author -
    // @description 3/17/2025, 10:19:57 AM
    // @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
    // @grant GM_getValue

    // ==/UserScript==

    function isVisible(el) {
    return !!el.offsetParent;
    }

    VM.shortcut.register(GM_getValue('is-unread-binding', 'c-s-a'), () => {
    console.log("CSA");
    const spans = Array.from(document.querySelectorAll('span')).filter(el => el.textContent.includes('unread') && isVisible(el))
    if (spans.length == 1) {
    spans[0].click();
    }
    })