Greasy Fork

来自缓存

Greasy Fork is available in English.

ChatGPT Chat bulk delete (drag to trash + fast retry)

Multi-select chats and delete them in bulk via drag-to-trash with fast parallel delete + retry

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
sbscm
日安装量
0
总安装量
4
评分
0 0 0
版本
1.3.1
创建于
2025-11-26
更新于
2025-11-26
大小
12.0 KB
许可证
MIT
适用于

# ChatGPT Chat Bulk Delete (Drag to Trash + Fast Retry)

Tampermonkey/Greasemonkey userscript that lets you multi-select ChatGPT chats in the sidebar and delete them quickly by dragging them onto a trash icon.

## Features

- Multi-select chats in the left sidebar:
- Single-click to toggle selection.
- Shift+Click to select a range.
- Floating trash icon at the bottom-left:
- Appears only when at least one chat is selected.
- Shows a badge with the number of selected chats.
- Drag-to-delete:
- Drag any selected chat onto the trash icon to delete all selected chats.
- Fast parallel delete:
- All delete calls are fired in parallel for speed.
- Smart retry:
- Automatically retries only retryable failures (e.g. 429/5xx, network errors).
- Failed items are highlighted with a red border.
- Keeps problematic items selected so you clearly see what did not delete.
- Double-click to open a chat:
- Double-click on a chat entry to open it as usual.
- Auth token prefetch:
- The script requests the auth token in the background so the first delete starts as fast as possible.

## Requirements

- A modern browser (Chrome, Firefox, etc.).
- A userscript manager, for example:
- [Tampermonkey](https://www.tampermonkey.net/)
- [Violentmonkey](https://violentmonkey.github.io/)
- A logged-in session on .

## Installation

1. Install Tampermonkey (or another userscript manager) in your browser.
2. Save the script file locally:
- Create a new file called `chatgpt-chat-bulk-delete.user.js`.
- Paste the contents of the script from the section below into that file and save it.
3. Open the saved `chatgpt-chat-bulk-delete.user.js` file in your browser:
- Drag-and-drop it into a browser window, **or**
- Use `File -> Open` and select the file.
4. Your userscript manager should open an install prompt.
5. Confirm installation.

The script is configured to run on:

- `https://chatgpt.com/*`

## Usage

1. Open and log in.
2. In the left sidebar under **Your chats**, you will see your normal conversation list.
3. Select chats:
- Click a chat to toggle selection.
- Shift+Click between two chats to select the whole range.
4. When one or more chats are selected:
- A circular trash icon appears bottom-left.
- A small badge on the trash icon shows how many chats are selected.
5. Drag-to-delete:
- Drag any of the selected chats onto the trash icon.
- All selected chats are sent for deletion in parallel.
6. If some deletions fail:
- Those chats remain in the list.
- They get a red border (`tm-delete-failed`) and stay selected.
- The script automatically retries retryable failures a couple of times.
7. Double-click any chat in the sidebar to open it in the main view.

## Error Handling and Retries

- Treated as *retryable*:
- HTTP `429`, `500`, `502`, `503`, `504`.
- Network errors (no HTTP status) are also treated as retryable.
- Other non-2xx status codes are considered permanent failures and not retried.
- Config constants (at the top of the script):
- `MAX_DELETE_ATTEMPTS = 2`
- `RETRY_DELAY_MS = 700` (milliseconds)

You can tweak these values if you want more retries or a different delay.

## Technical Details

- Uses `GM_xmlhttpRequest` to:
- Fetch `https://chatgpt.com/api/auth/session` and extract `accessToken`.
- Send `PATCH` requests to `https://chatgpt.com/backend-api/conversation/{conversationId}` with `{"is_visible": false}` to hide/delete chats.
- Extracts conversation IDs from sidebar links with the pattern `/c/{conversationId}` in the `href`.
- Uses `Promise.allSettled` so all delete requests run in parallel and you still get a per-item success/fail result.
- Fixed-position trash zone (`#tm-trash-zone`) is shown/hidden via CSS transitions based on selection count.

## Permissions

Tampermonkey grants:

- `GM_addStyle` — injects custom CSS (selection styling + trash UI).
- `GM_xmlhttpRequest` — talks directly to ChatGPT’s backend with your auth token.

Host permissions:

- `@match https://chatgpt.com/*`
- `@connect chatgpt.com`

No data is sent to third-party servers; all requests go directly to `chatgpt.com` using your existing session.

## Uninstall

1. Open your userscript manager dashboard.
2. Find **ChatGPT Chat bulk delete (drag to trash + fast retry)**.
3. Disable or remove the script.

## License

MIT License.