Auto Close Google AI Studio Settings Panel

Close the Run settings panel after page aistudio load

Ajankohdalta 1.9.2025. Katso uusin versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Auto Close Google AI Studio Settings Panel
// @namespace   Violentmonkey Scripts
// @match       https://aistudio.google.com/*
// @run-at      document-start
// @version     1.1
// @author      Bui Quoc Dung
// @description Close the Run settings panel after page aistudio load
// @license     MIT
// ==/UserScript==

(function () {
  'use strict';

  const DELAY_MS = 2000;
  const SELECTOR = 'button[aria-label="Close run settings panel"]';
  let lastHandledUrl = null;

  function closeSettingsPanelOnce() {
    if (lastHandledUrl === location.href) return;
    lastHandledUrl = location.href;

    setTimeout(() => {
      try {
        const button = document.querySelector(SELECTOR);
        if (button) button.click();
      } catch (e) {
      }
    }, DELAY_MS);
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', closeSettingsPanelOnce);
  } else {
    closeSettingsPanelOnce();
  }

  (function patchHistory() {
    const _push = history.pushState;
    const _replace = history.replaceState;

    history.pushState = function (...args) {
      const res = _push.apply(this, args);
      window.dispatchEvent(new Event('locationchange'));
      return res;
    };

    history.replaceState = function (...args) {
      const res = _replace.apply(this, args);
      window.dispatchEvent(new Event('locationchange'));
      return res;
    };

    window.addEventListener('popstate', () =>
      window.dispatchEvent(new Event('locationchange'))
    );
    window.addEventListener('locationchange', closeSettingsPanelOnce);
  })();
})();