A browser console script to batch delete Grok chat conversations on X (Twitter).
X's Grok does not provide a batch deletion feature for chat history. Deleting conversations one by one becomes tedious when you have many. This script automates the process through the browser console.
Safety: All operations run locally in your browser. No data is sent to third-party servers.
Prerequisite: Open the chat history popup/dialog in Grok first.
- Copy the entire code from
console_del_xgrok_chats.jsto your browser console - Open DevTools → Network tab, find any request to
https://x.com/i/api/ - Copy the
authorizationheader value (starts withBearer) - Call:
deleteGrokChats('Bearer your-authorization-token')
Get Authorization Token: In Network tab → Click any x.com/i/api/ request → Headers → Copy authorization value
Custom Class: If default class doesn't match, use: deleteGrokChats(auth, 'your-classname')
QueryId: The script auto-detects queryId. If deletion fails, manually get it:
- Delete a conversation manually in Grok
- In Network tab, find the request URL:
/graphql/QUERY_ID/ConversationItem_DeleteConversationMutation - Use:
deleteGrokChats(auth, classname, 'QUERY_ID')
Default class: css-175oi2r r-13awgt0 r-pm9dpa r-bnwqim r-13qz1uu
deleteGrokChats('Bearer your-authorization-token', 'your-queryId', 'your-classname')- "Element not found": Make sure chat history popup is open
- "Cannot get CSRF token": Ensure you're logged in and refresh the page
- "No conversation IDs found": Verify popup is open and contains conversations
- Deletion fails: QueryId might be different. Get it from Network tab and pass as third parameter
MIT License
用于在 X (Twitter) 上批量删除 Grok 聊天记录的浏览器控制台脚本。
X 的 Grok 没有提供批量删除聊天记录的功能。当聊天记录很多时,一个个删除非常繁琐。这个脚本通过浏览器控制台自动化删除过程。
安全性:所有操作都在本地浏览器运行,不会向第三方服务器发送任何数据。
前提条件:必须先打开 Grok 的聊天历史弹窗。
- 复制
console_del_xgrok_chats.js中的整个代码到浏览器控制台 - 打开开发者工具 → Network 标签,找到任意
https://x.com/i/api/开头的请求 - 复制请求头中的
authorization值(以Bearer开头) - 调用:
deleteGrokChats('Bearer your-authorization-token')
获取 Authorization Token:Network 标签 → 点击任意 x.com/i/api/ 请求 → Headers → 复制 authorization 值
自定义 Class:如果默认 class 不匹配,使用:deleteGrokChats(auth, 'your-classname')
QueryId:脚本会自动检测 queryId。如果删除失败,可手动获取:
- 在 Grok 中手动删除一个对话
- 在 Network 标签中找到请求 URL:
/graphql/QUERY_ID/ConversationItem_DeleteConversationMutation - 使用:
deleteGrokChats(auth, classname, 'QUERY_ID')
默认 class:css-175oi2r r-13awgt0 r-pm9dpa r-bnwqim r-13qz1uu
deleteGrokChats('Bearer your-authorization-token', 'your-queryId', 'your-classname')- "找不到元素":确保已打开聊天历史弹窗
- "无法获取 CSRF token":确保已登录并刷新页面
- "未找到 conversation ID":确认弹窗已打开且包含聊天记录
- 删除失败:queryId 可能不同,从 Network 标签获取并作为第三个参数传入
MIT License