Save a Gemini message to Google Docs

Uses Ctrl+Shift+D to export a Gemini message to Google Docs, visually highlighting each interacted UI element. Handles UI variations.

作者
TakashiSasaki
今日安裝
1
安裝總數
2
評價
0 0 0
版本
0.2.3
建立日期
2025-05-09
更新日期
2025-05-09
尺寸
13.2 KB
授權條款
MIT
腳本執行於

✨ Save a Gemini message to Google Docs ✨

📝 Description

This Tampermonkey UserScript provides a convenient keyboard shortcut (Ctrl + Shift + D) to streamline the process of exporting a specific message from a Google Gemini conversation directly to Google Docs.

The script automates a sequence of UI interactions:

  1. It first locates and clicks the "More options" (three-dots) menu associated with a message. It intelligently selects the topmost visible "More options" button if multiple are present on screen.
  2. It then attempts a primary path:
    • Waits briefly for the menu to open.
    • Clicks the "Export to..." button within that menu.
    • Waits again for the next menu.
    • Clicks the "Export to Docs" button.
  3. If the "Export to..." button is not found (which can happen with different UI layouts, e.g., wider screens), the script attempts an alternative path:
    • It first emulates an "Escape" key press to close any menu opened by the first step.
    • It then clicks the "Share & export" button (often found in the main response footer).
    • Waits briefly for its menu to open.
    • Finally, clicks the "Export to Docs" button from this menu.

Throughout this process, each UI element the script interacts with is briefly highlighted just before it's clicked, providing visual feedback of the automation steps.

⚙️ Features

  • One-Click Export Shortcut (Ctrl + Shift + D): Initiates a multi-step process to export a Gemini message to Google Docs.
  • Intelligent Element Selection:
    • For the initial "More options" menu, it targets the topmost visible button on the screen if multiple are present.
    • All element selections are viewport-aware, ensuring the script interacts with buttons currently visible on the screen.
  • Dual-Path Automation:
    • Primary Path: Attempts to use the "More options" -> "Export to..." -> "Export to Docs" sequence.
    • Alternative Path: If the primary path's "Export to..." button isn't found, it automatically tries a secondary sequence: "Share & export" -> "Export to Docs".
  • UI Feedback (Highlighting): Each button in the automation sequence (More options, Export to... or Share & export, and Export to Docs) is briefly highlighted before being clicked, making the script's actions visible.
  • Automatic Menu Closing: When switching from the primary to the alternative path, the script emulates an "Escape" key press to close any previously opened menu, preventing UI conflicts.
  • Robust Element Polling: Waits for UI elements to appear and become visible in the viewport before interacting with them.
  • Wide URL Matching: Designed to work on both https://gemini.google.com/app/* (specific conversations) and https://gemini.google.com/app (the main app page).
  • Console Logs: Provides detailed logs in the browser's developer console for each step and for debugging purposes.

🚀 Installation & Usage

  1. Install Tampermonkey: Ensure you have the Tampermonkey browser extension installed (available for Chrome, Edge, Firefox, Opera, etc.).
  2. Install this script: Click the "Install" button on the GreasyFork page for this script.
  3. Open a Gemini Conversation: Navigate to https://gemini.google.com/app and have a conversation with at least one message displayed.
  4. Execute the Shortcut:
    • Scroll if necessary to bring the desired message (and its "More options" or "Share & export" button) into the browser's viewport.
    • Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>D</kbd>.
  5. Observe the Automation: The script will:
    • Highlight and click the relevant "More options" (or "Share & export") button for the topmost visible message (or the one it finds for the alternative path).
    • Highlight and click the subsequent "Export to..." (if applicable) and "Export to Docs" buttons.
  6. Check Google Docs: After the sequence completes, a new Google Document should be created with the content of the exported Gemini message.

Note: The script relies on specific data-test-id attributes and CSS classes present in Gemini's UI. Changes to Gemini's website structure may require updates to the script's selectors.

👨‍💻 Developer

Takashi Sasaki

🌐 Homepage

https://x.com/TakashiSasaki

📄 License

MIT