Skip to content

Instantly share code, notes, and snippets.

@0xdevalias
Last active August 26, 2025 05:31
Show Gist options
  • Select an option

  • Save 0xdevalias/79dadd5bbd0ab59c50985c0f8e03683f to your computer and use it in GitHub Desktop.

Select an option

Save 0xdevalias/79dadd5bbd0ab59c50985c0f8e03683f to your computer and use it in GitHub Desktop.
CSS Selectors for Gmail Things

CSS Selectors for Gmail Things

Table of Contents

Notes

Select the 'Snooze' button that appears on hover on the right side of an email in the list view, and set it's background to be red:

$$('div.UI table > tbody > tr > td ul[role="toolbar"] > li[data-tooltip="Snooze"]')[0].style.backgroundColor = '#f00'

When the Snooze 'Select date and time' dialog is open, we can set the time in the textbox as follows:

$('div[role="dialog"] input[aria-label="Time"]').value = '01:23'

We could set the time to 5min from the current time with something like:

var fiveMinutesLater = new Date(Date.now() + 5 * 60000).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })

$('div[role="dialog"] input[aria-label="Time"]').value = fiveMinutesLater

See Also

My Other Related Deepdive Gist's and Projects

@0xdevalias

Copy link
Copy Markdown
Author

https://chat.openai.com/chat

Write a tampermonkey script that will efficiently notice when a div[role="dialog"] becomes visible, checks if it has a span[role='heading'] with the text "Select date and time", and if so, updates the value of the input[aria-label='Time'] 

This should run on gmail
// ==UserScript==
// @name         Update Time in Date and Time Selector
// @namespace    http://gmail.com/
// @version      0.1
// @description  Update the time input in the date and time selector on Gmail
// @author       You
// @match        https://mail.google.com/*
// @grant        none
// ==/UserScript==

// create a new MutationObserver to watch for changes to the DOM
const observer = new MutationObserver(() => {
  // check if the dialog with the date and time selector is visible
  const dialog = document.querySelector('div[role="dialog"][aria-label="Select date and time"]');
  if (!dialog || !dialog.isVisible()) {
    return;
  }

  // check if the dialog has a heading with the text "Select date and time"
  const heading = dialog.querySelector('span[role="heading"]');
  if (!heading || heading.textContent !== "Select date and time") {
    return;
  }

  // update the value of the time input
  const input = dialog.querySelector('input[aria-label="Time"]');
  if (input) {
    input.value = "12:00 PM";
  }
});

// start observing the DOM
observer.observe(document.body, {
  childList: true,
  subtree: true
});
// ==UserScript==
// @name         Update Time Input in Gmail Dialog
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Updates the value of the time input in a Gmail dialog
// @author       You
// @match        https://mail.google.com/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  // Observe changes to the DOM
  const observer = new MutationObserver(checkForDialog);
  observer.observe(document.body, { childList: true, subtree: true });

  // Check for dialog with heading "Select date and time"
  function checkForDialog() {
    const dialog = document.querySelector('div[role="dialog"][aria-hidden="false"]');
    if (!dialog) return;

    const heading = dialog.querySelector('span[role="heading"]');
    if (!heading || heading.textContent !== "Select date and time") return;

    // Update value of time input
    const timeInput = dialog.querySelector('input[aria-label="Time"]');
    if (timeInput) timeInput.value = "12:00 PM";
  }
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment