Skip to content

Create gemini.js #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

wsuff
Copy link
Contributor

@wsuff wsuff commented Mar 11, 2025

JS Code to export Gemini Chat to JSON (HTML still)

Key Adaptations

  1. Selectors:
    • 'chat-window-content .conversation-container' to get each turn.
    • 'user-query-content .query-text' to get user input.
    • 'response-container .response-content' to get model output.
  2. extractTextContent and extractHTMLContent:
    • extractTextContent now uses innerText to get plain text from user queries.
    • extractHTMLContent uses innerHTML to preserve formatting in model responses.
  3. Role Assignment:
    • User queries are assigned the role: 'user'.
    • Model responses are assigned the role: 'assistant'.
  4. Position Sorting:
    • The getNodePosition function and sorting logic are retained to ensure the correct conversation order.
  5. JSON Structure:
    • The output JSON includes title, timestamp, and conversation (an array of messages).

How to Use

  1. Open the Gemini chat you want to extract.
  2. Open the browser console.
  3. Paste the script.
  4. Press Enter.

This script should now provide you with a JSON file in the desired format, consistent with the ChatArchiver's expectations.

wsuff added 2 commits March 11, 2025 11:05
JS Code to export Gemini Chat to JSON (HTML still)
Add Usage Details for Gemini.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant