LS-RP Forums – Love All + Post Counter

One-click “Love All” (reaction id 18) for the current LS-RP forum topic page + live post counter.

作者
blancoleopardo
日安装量
0
总安装量
0
评分
0 0 0
版本
1.0.0
创建于
2025-08-31
更新于
2025-08-31
大小
8.0 KB
许可证
All Rights Reserved
适用于

## What this does

Adds a floating button to LS-RP’s forums that:

* Reacts with **Love (reaction id 18)** to **every un-reacted post on the current topic page** in one click.
* Shows a **live post counter** (updates as posts load).
* Gives **toast notifications** for progress, completion, and **rate-limit** pauses.

No external services, no tracking, no data leaves `community.ls-rp.com`.

---

## Why?

Bulk “Love” can be tedious on long topics. This script speeds that up while respecting CSRF, login state, and common forum rate limits. The post counter is handy for patrol logs, faction reviews, and general thread bookkeeping.

---

## Features

* **One-click bulk Love** for the *current page* only (safe and predictable).
* **Rate-limit aware:** Automatically pauses when the forum responds with `429 Too Many Requests`. Honors `Retry-After` when provided.
* **Retry with backoff:** Transient failures are retried up to a small max.
* **Theme-aware UI:** Button, badge, and toasts adapt to light/dark.
* **Keyboard accessible:** Focus the button and press **Enter** or **Space**.
* **Non-blocking UI:** You can scroll or navigate while it works.
* **No special permissions:** `@grant none`, runs only on the LS-RP forum.

---

## How to use

1. Install with a userscript manager (Tampermonkey/Violentmonkey/etc.).
2. Visit any LS-RP topic page: `https://community.ls-rp.com/forums/*`.
3. Look for the **floating heart button** at the bottom-right.
4. Click it. The script will:

* Find all posts on the page you **haven’t reacted to**.
* Send Love (id `18`) to each, one by one, with a tiny jittered delay.
* Show a toast on completion with ✅ / ❌ counts.

> Tip: If the topic auto-loads more posts (infinite scroll or manual page change), click the button again to process the newly loaded posts.

---

## Compatibility

* **Site:** LS-RP Community Forums (Invision Community).
* **Managers:** Tampermonkey, Violentmonkey, Userscripts, etc.
* **Browsers:** Chromium-based and Firefox. (Any modern browser that your manager supports.)

---

## Privacy & permissions

* **No data collection.**
* **Network calls:** Only `GET` requests to the forum’s own reaction endpoint (same origin), using your existing session & CSRF token.
* **No iframes, no external scripts.** The icon uses a small GIF from Imgur for the button; you can swap it if you prefer a local asset.

---

## Limits & notes

* **Current page only.** It won’t traverse multiple pages for you.
* **Login required.** Obviously, you must be logged in and allowed to react.
* **Locked/archived posts:** The forum will reject reactions; these will count as failures.
* **DOM-fragile:** If LS-RP changes their forum templates or CSS classes for the react UI, the script may need an update.
* **Respect forum rules.** Bulk reactions may be frowned upon in some contexts—use responsibly.

---

## Troubleshooting / FAQ

**“It says ‘No un-reacted posts found…’ but I see posts!”**
You may have already reacted to them, or the forum is using a different DOM structure on that page (staff views, special templates). Try reloading; if it persists, the selectors may need an update.

**“I’m getting rate-limited.”**
Normal. The forum can throttle reactions. The script auto-pauses on `429` and resumes after `Retry-After` (or a safe fallback). You’ll see a toast with the pause length.

**“Some posts failed.”**
Happens with locked/hidden posts, expired sessions, or changed CSRF keys. Log out/in, reload the page, and try again. The script also retries transient errors with exponential backoff.

**“The button/badge is covering other UI.”**
You can nudge them via the config (see below). The post counter’s vertical offset is `badgeBottom`.

---

## Configuration (optional)

Open the script and adjust the `CONFIG` at the top:

```js
const CONFIG = {
reactionId: 18, // Love
likeDelay: 500, // base ms between reactions
likeDelayJitterPct: 0.4,// ±40% jitter to look human
badgeBottom: 150, // px from bottom for the post counter
counterDebounce: 250, // ms debounce for counter updates
maxRetries: 3, // per post
rateLimitPause: 30000 // ms fallback if no Retry-After header
};
```

* **Change reaction type:** Set `reactionId` to another forum reaction if you know the id.
* **Slow it down:** Increase `likeDelay` (and/or reduce jitter) for a gentler pace.
* **Move UI:** Tweak `badgeBottom` or edit the inline styles for the button.

---

## How it works (technical)

* Finds **unselected** Invision react buttons on the page and attempts to locate a **direct Love link**; if only a **default reaction** is present, it **rebuilds the URL** with `reaction=18` and the existing `csrfKey`.
* Sends **XHR-style fetch** requests with `X-Requested-With: XMLHttpRequest` to minimize page jank.
* Handles **`429`** with `Retry-After` parsing (seconds or HTTP-date), otherwise uses a conservative fallback pause.
* Uses a **MutationObserver** to keep the post counter accurate as content changes.

---

## Changelog

**v1.0.0** — Initial release (bulk Love + live counter + rate-limit handling + toasts + theme awareness + keyboard support).

---

## Feedback

Bugs or suggestions? Use the **Feedback**/**Issues** section on GreasyFork so everything stays in one place.