An open API service indexing awesome lists of open source software.

https://github.com/junaire/x-reply-clean-skill


https://github.com/junaire/x-reply-clean-skill

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# X Reply Cleaner

Block scammer accounts on X from the X scammer blacklist service.

## Requirements

- macOS
- Google Chrome
- Node.js
- Chrome is logged in to the X account that should block scammers

The script only supports macOS + Chrome because it reads Chrome cookies from the macOS keychain and Chrome profile database.

## Run Once

```sh
node scripts/block-scammers.mjs
```

The default run is intentionally conservative:

- fetches up to 100 user ids per batch
- waits 1500 ms between block requests
- prints compact progress every 25 handled accounts
- stops immediately if X returns a rate limit response
- advances the cursor after each blocked or already-gone account

## Cursor

The blacklist endpoint accepts `after=`. The script automatically stores the last handled `user_id` in:

```text
~/.x-reply-cleaner.cursor
```

On the next run, the saved value is sent as `after`, so the blacklist service can continue after the previous run's last handled account and avoid repeat work.

The cursor advances after each account that is blocked or already gone from X. If a block request fails with a real blocker, such as rate limiting or an unexpected API error, the run stops and saves the cursor at the last account that was actually handled. The failed account is retried by a later run.

`404 User not found` from X is treated as resolved and counted as `skipped_not_found`, because there is no remaining account to block.

Useful cursor options:

```sh
node scripts/block-scammers.mjs --cursor-file ~/.x-reply-cleaner.cursor
node scripts/block-scammers.mjs --no-cursor
```

## Scheduled Run

Recommended: run it once per day with a scheduled task.

For scheduled or long-running use, enable persisted cookies:

```sh
node scripts/block-scammers.mjs --persist-cookie
```

This reads `X_COOKIE` from `~/.x-reply-cleaner.env`. If the file does not exist, or if the saved cookie is malformed or rejected by X, the script refreshes the cookie from Chrome and writes the file again with restricted permissions.

Example cron entry for running once per day at 03:15:

```cron
15 3 * * * cd /path/to/x-reply-clean-skill && /usr/local/bin/node scripts/block-scammers.mjs --persist-cookie >> "$HOME/Library/Logs/x-reply-cleaner.log" 2>&1
```

Use the actual absolute paths for this skill directory and your Node binary.

## Runtime

This script is intentionally slow. It blocks accounts one by one and waits between requests so it is gentler on X. The default delay is 1500 ms per account, and X network latency can add more time.

Adjust the delay only when needed:

```sh
node scripts/block-scammers.mjs --persist-cookie --delay-ms 3000
```

For a longer unattended run, process multiple batches and pause between them:

```sh
node scripts/block-scammers.mjs --persist-cookie --max-batches 5 --batch-sleep-ms 300000
```

If X returns `429 Rate limit exceeded`, the script stops immediately and prints a suggested slower retry command.

## Options

```sh
node scripts/block-scammers.mjs --help
```

Useful options:

- `--api `: blacklist endpoint URL.
- `--limit `: pass `limit=` to the blacklist endpoint per batch, default 100.
- `--chrome-profile `: Chrome profile directory, default `Default`.
- `--persist-cookie`: read/write `~/.x-reply-cleaner.env`; recommended for scheduled runs.
- `--cursor-file `: read/write the saved `after` cursor, default `~/.x-reply-cleaner.cursor`.
- `--no-cursor`: do not read, pass, or update the saved cursor.
- `--dry-run`: preview accounts without blocking.
- `--delay-ms `: delay between X block requests, default 1500.
- `--max-batches `: fetch and process up to `n` batches in one run, default 1.
- `--batch-sleep-ms `: delay between batches.
- `--verbose`: print one line per account.