Skip to content

Instantly share code, notes, and snippets.

@TomLisankie
Created April 26, 2026 17:01
Show Gist options
  • Select an option

  • Save TomLisankie/d4d46e39c0f460831d1e315ece2e0177 to your computer and use it in GitHub Desktop.

Select an option

Save TomLisankie/d4d46e39c0f460831d1e315ece2e0177 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Google Calendar Auto-Click Today
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Clicks the "Today" button on Google Calendar every 10 minutes and refreshes at midnight
// @match https://calendar.google.com/*
// @grant none
// ==/UserScript==
(function () {
"use strict";
function clickTodayButton() {
const xpath = "//button[span[text()='Today']]";
const result = document.evaluate(
xpath,
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null,
);
const matchingButtons = [];
for (let i = 0; i < result.snapshotLength; i++) {
matchingButtons.push(result.snapshotItem(i));
}
if (matchingButtons.length > 0) {
matchingButtons[0].click();
}
}
function scheduleMidnightRefresh() {
const now = new Date();
const midnight = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate() + 1, // next day
0, 0, 0, 0, // 00:00:00.000
);
const msUntilMidnight = midnight - now;
setTimeout(function () {
location.reload();
}, msUntilMidnight);
}
// Run once on page load (after a short delay to let the UI render)
setTimeout(clickTodayButton, 3000);
// Then run every 10 minutes (600,000 ms)
setInterval(clickTodayButton, 10 * 60 * 1000);
// Schedule a full page refresh at midnight
scheduleMidnightRefresh();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment