Skip to content

Instantly share code, notes, and snippets.

@joeperpetua
Last active February 25, 2026 19:26
Show Gist options
  • Select an option

  • Save joeperpetua/60283e74370e7db94aabd41ba91472a1 to your computer and use it in GitHub Desktop.

Select an option

Save joeperpetua/60283e74370e7db94aabd41ba91472a1 to your computer and use it in GitHub Desktop.
This script enables Gemini temporary chat by default on page load
// ==UserScript==
// @name Gemini - Temporary Chat by default
// @namespace https://github.com/joeperpetua
// @version 2026-02-25
// @description Enables Gemini temporary chat by default
// @author joeperpetua
// @match https://gemini.google.com/app
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
(function() {
'use strict';
let running = false;
const observer = new MutationObserver(() => run());
/////////////////////////////////////////////////////////////////////////////
// If the script is failing due to slow connection or slow initialization, //
// increase sleepTime to a bigger number. //
/////////////////////////////////////////////////////////////////////////////
const sleepTime = 1500;
observer.observe(document.body, {
subtree: true,
childList: true,
attributes: false,
});
async function run() {
if (running) return
running = true;
const button = document.querySelector("[data-test-id='temp-chat-button']");
if (!button) {
running = false;
return;
}
console.log('[UserScript] Custom script [Gemini - Temporary Chat by default] is running...')
await sleep(sleepTime);
button.click();
observer.disconnect();
console.log('[UserScript] Custom script [Gemini - Temporary Chat by default] has been executed.')
return
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment