Google AI Studio | Clear Chat Button

Automates clicking chat turn options and delete buttons in Gemini.

作者
piknockyou
今日安裝
2
安裝總數
16
評價
1 0 0
版本
1.1
建立日期
2025-09-03
更新日期
2025-09-03
尺寸
8.0 KB
授權條款
未知
腳本執行於

Google AI Studio | Clear Chat Button

After their August 2025 interface revamp, Google removed the native clear button, making it difficult to quickly clear conversation history. This userscript restores the missing clear chat button in Google AI Studio.

Features

  • Restores Missing Functionality: Brings back the clear chat button that Google removed in their August 2025 AI Studio revamp
  • One-Click Clearing: Instantly clear all chat turns in your current prompt session
  • Integrated UI: Seamlessly integrates into the existing toolbar with native Material Design styling
  • Visual Feedback: Uses a refresh icon (🔄) with clear tooltip for easy identification
  • Error Handling: Robust error handling with console logging for debugging
  • Non-Intrusive: Doesn't modify existing functionality, only adds the clear feature

Installation

Requirements

Steps

  1. Install one of the userscript managers listed above
  2. Click the install link for this script
  3. The script will automatically activate on https://aistudio.google.com/prompts/*

Important Note: Google AI Studio is a single-page application (SPA). This means when you navigate from one section to a prompt page (without a full page reload), the userscript may not initialize properly. If the clear button doesn't appear after navigation, simply reload the page (F5 or Ctrl+R) to activate the script and display the button.

Usage

  1. Navigate to any prompt page in Google AI Studio (see important note above).
  2. Look for the new refresh button (🔄) in the top toolbar
  3. Click the button to clear all chat turns in the current session
  4. The script will automatically click the option buttons and delete buttons for you

How It Works

The script automates the manual process of:

  1. Clicking the options menu (⋯) on each chat turn
  2. Selecting the delete option from the dropdown menu
  3. Confirming the deletion

This process is now reduced to a single button click in the toolbar.

Compatibility

  • Browser: Chrome, Firefox, Safari, Edge
  • Userscript Manager: Violentmonkey, Tampermonkey, Greasemonkey
  • Platform: Google AI Studio (aistudio.google.com)

Technical Details

  • Language: JavaScript (ES6+)
  • Framework: None (vanilla JavaScript)
  • Dependencies: None
  • CSP Compliant: Uses DOM manipulation instead of innerHTML to avoid Content Security Policy restrictions

Configuration

The script includes configurable selectors in case Google changes their DOM structure:

const CHAT_TURN_OPTIONS_SELECTOR = 'ms-chat-turn-options span[class="material-symbols-outlined notranslate ms-button-icon-symbol ng-star-inserted"]';
const DELETE_BUTTON_MENU_SELECTOR = 'div.mat-mdc-menu-content > button:first-of-type';
const DELETE_BUTTON_TEXT = "delete Delete";

Troubleshooting

Button Not Appearing

  • Ensure you're on a prompt page (https://aistudio.google.com/prompts/*)
  • Check that your userscript manager is enabled
  • Open browser console (F12) and look for script initialization logs

Script Not Working

  • Open browser console (F12)
  • Look for error messages starting with [Gemini Chat Cleaner]
  • Verify the page structure hasn't changed (Google may update their interface)

Console Logs

The script provides detailed logging:

  • [Gemini Chat Cleaner] Script loaded and starting...
  • [Gemini Chat Cleaner] Current URL: [URL]
  • [Gemini Chat Cleaner] Toolbar found, creating button...
  • [Gemini Chat Cleaner] Button successfully added to toolbar

Changelog

v1.0

  • Initial release to restore clear chat functionality after Google's August 2025 AI Studio revamp
  • Toolbar integration with refresh icon
  • Error handling and logging
  • CSP-compliant DOM manipulation
  • Addresses the removal of native clear chat button

License

This userscript is provided as-is for personal use. Feel free to modify and distribute according to your needs.

Support

If you encounter issues:

  1. Check the troubleshooting section above
  2. Verify you're using a compatible userscript manager
  3. Ensure you're on the correct Google AI Studio URL
  4. Check browser console for error messages

Author

Created with assistance from AI tools for enhanced productivity in Google AI Studio workflows.