diff --git a/AGENTS.md b/AGENTS.md
index 69e7f51..1d45faa 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -26,5 +26,5 @@ Beat Saber Plus itself (game mod) exposes the socket; this repo is only the HTML
- **Live API calls are proxied** same-origin via `src/server/serve.ts`: `/api/beatleader?path=/...`, `/api/beatsaver?path=/...` (CORS).
- **Map correlation is hash-based**: resolve BeatSaver map/hash first, then BeatLeader leaderboards via `/leaderboards/hash/{hash}`.
- **Friend scores** use `/leaderboard/{leaderboardId}` for stable `playerId` fields.
-- **Mutual friends**: intersection of `/player/{id}/followers?type=Following` and `type=Followers` (paged by `page` + `count`).
+- **Mutual friends**: intersection of `/player/{id}/followers?type=Following` and `type=Followers` (paged by `page` + `count`). **`all` friends**: union of both lists (deduped).
- **`#friendScores`**: best accuracy per friend for the current map, sorted descending.
diff --git a/README.md b/README.md
index 893eec2..73c9722 100644
--- a/README.md
+++ b/README.md
@@ -21,10 +21,12 @@ Configuration is `overlay.toml` in the repo root (copy from `overlay.toml.exampl
- `chat_request_database` — absolute path to Beat Saber Plus `ChatRequest/Database.json`. The server serves that file as `ChatRequest.json` over HTTP (no symlink).
- `beatleader_player_id` — default BeatLeader id for friend scores (the server logs a warning if this is missing).
-- Overlay UI defaults — optional toggles and layout matching the settings dialog: `cover`, `map_info`, `time`, `score`, `friends`, `friend_mode` (`mutual` \| `following` \| `followers`), `bsr`, `right`, `bottom`, `scale`, `fade`.
+- Overlay UI defaults — optional toggles and layout matching the settings dialog: `cover`, `map_info`, `time`, `score`, `friends`, `friend_mode` (`mutual` \| `following` \| `followers` \| `all`), `bsr`, `right`, `bottom`, `scale`, `fade`.
Mutual friend mode shows scores from players that you follow and that follow you back on Beatleader. Or in other words, users that are in both your following and follower list.
+Use `friend_mode = "all"` to include anyone you follow **or** anyone who follows you (union, deduped by player id).
+
## Usage
Clone the repo and run `deno task serve` as above.
diff --git a/index.html b/index.html
index e56002e..e1cf774 100644
--- a/index.html
+++ b/index.html
@@ -75,6 +75,7 @@
Followed + follower (mutual)
Following (I follow them)
Followers (they follow me)
+ All friends (following or followers)
Player id:
e.g. pleb
diff --git a/index.js b/index.js
index 34d91bc..2c1b60d 100644
--- a/index.js
+++ b/index.js
@@ -188,6 +188,23 @@ async function fetchFriends(playerId, mode, maxPages = 100) {
if (mode === "followers") {
return followers.map((entry) => normalizeFollowerEntry(entry));
}
+ if (mode === "all") {
+ const seen = /* @__PURE__ */ new Set();
+ const out = [];
+ for (const entry of following) {
+ const id = String(entry.id);
+ if (seen.has(id)) continue;
+ seen.add(id);
+ out.push(normalizeFollowerEntry(entry));
+ }
+ for (const entry of followers) {
+ const id = String(entry.id);
+ if (seen.has(id)) continue;
+ seen.add(id);
+ out.push(normalizeFollowerEntry(entry));
+ }
+ return out;
+ }
return followers.filter((entry) => followingIds.has(String(entry.id))).map((entry) => normalizeFollowerEntry(entry));
}
function normalizeAccuracy(value) {
@@ -600,7 +617,7 @@ function beginFriendScoresForNewMapContext() {
friendScoresList.replaceChildren();
friendScoresPanel.classList.remove("has-items");
friendScoresPanel.classList.add("is-loading");
- friendScoresEmpty.textContent = "Loading mutual friend scores...";
+ friendScoresEmpty.textContent = "Loading friend scores...";
}
async function refreshMapFriendScores() {
const hash = currentMapHash;
@@ -621,7 +638,7 @@ async function refreshMapFriendScores() {
friendScoresList.replaceChildren();
friendScoresPanel.classList.remove("has-items");
friendScoresPanel.classList.add("is-loading");
- friendScoresEmpty.textContent = "Loading mutual friend scores...";
+ friendScoresEmpty.textContent = "Loading friend scores...";
const requestId = ++friendScoreRequestId;
try {
const relKey = friendsRelationListKey(playerId);
@@ -656,7 +673,7 @@ async function refreshMapFriendScores() {
]));
const mutualFriendIds = new Set(friends.map((f) => f.id));
if (mutualFriendIds.size === 0) {
- const relationLabel = settings.friendMode === "following" ? "No followed BeatLeader players" : settings.friendMode === "followers" ? "No BeatLeader followers" : "No mutual BeatLeader followers";
+ const relationLabel = settings.friendMode === "following" ? "No followed BeatLeader players" : settings.friendMode === "followers" ? "No BeatLeader followers" : settings.friendMode === "all" ? "No followed or follower BeatLeader players" : "No mutual BeatLeader followers";
clearFriendScores(relationLabel);
return;
}
diff --git a/overlay.toml.example b/overlay.toml.example
index 415f3e5..1d05a51 100644
--- a/overlay.toml.example
+++ b/overlay.toml.example
@@ -12,7 +12,7 @@ map_info = true
time = true
score = true
friends = true
-friend_mode = "mutual" # mutual | following | followers
+friend_mode = "mutual" # mutual | following | followers | all
bsr = false
right = false
bottom = true
diff --git a/src/client/beatleader.ts b/src/client/beatleader.ts
index 461facb..333cd9b 100644
--- a/src/client/beatleader.ts
+++ b/src/client/beatleader.ts
@@ -196,6 +196,23 @@ export async function fetchFriends(playerId: string, mode: FriendMode, maxPages
if (mode === "followers") {
return followers.map((entry) => normalizeFollowerEntry(entry as BeatLeaderFollower));
}
+ if (mode === "all") {
+ const seen = new Set();
+ const out: BeatLeaderFollower[] = [];
+ for (const entry of following) {
+ const id = String(entry.id);
+ if (seen.has(id)) continue;
+ seen.add(id);
+ out.push(normalizeFollowerEntry(entry as BeatLeaderFollower));
+ }
+ for (const entry of followers) {
+ const id = String(entry.id);
+ if (seen.has(id)) continue;
+ seen.add(id);
+ out.push(normalizeFollowerEntry(entry as BeatLeaderFollower));
+ }
+ return out;
+ }
return followers
.filter((entry) => followingIds.has(String(entry.id)))
.map((entry) => normalizeFollowerEntry(entry as BeatLeaderFollower));
diff --git a/src/client/index.ts b/src/client/index.ts
index 13d0255..c786e71 100644
--- a/src/client/index.ts
+++ b/src/client/index.ts
@@ -484,7 +484,7 @@ function beginFriendScoresForNewMapContext() {
friendScoresList.replaceChildren();
friendScoresPanel.classList.remove("has-items");
friendScoresPanel.classList.add("is-loading");
- friendScoresEmpty.textContent = "Loading mutual friend scores...";
+ friendScoresEmpty.textContent = "Loading friend scores...";
}
async function refreshMapFriendScores() {
@@ -506,7 +506,7 @@ async function refreshMapFriendScores() {
friendScoresList.replaceChildren();
friendScoresPanel.classList.remove("has-items");
friendScoresPanel.classList.add("is-loading");
- friendScoresEmpty.textContent = "Loading mutual friend scores...";
+ friendScoresEmpty.textContent = "Loading friend scores...";
const requestId = ++friendScoreRequestId;
try {
const relKey = friendsRelationListKey(playerId);
@@ -542,6 +542,8 @@ async function refreshMapFriendScores() {
? "No followed BeatLeader players"
: settings.friendMode === "followers"
? "No BeatLeader followers"
+ : settings.friendMode === "all"
+ ? "No followed or follower BeatLeader players"
: "No mutual BeatLeader followers";
clearFriendScores(relationLabel);
return;
diff --git a/src/client/live-friends.test.ts b/src/client/live-friends.test.ts
index fdb7abc..644acd9 100644
--- a/src/client/live-friends.test.ts
+++ b/src/client/live-friends.test.ts
@@ -1,4 +1,4 @@
-import { assert } from "jsr:@std/assert";
+import { assert, assertGreaterOrEqual } from "jsr:@std/assert";
import { fetchFriends } from "./beatleader.ts";
const PLAYER_ID = "76561199407393962";
@@ -12,3 +12,20 @@ Deno.test({
assert(mutuals.length > 0, `Expected mutual friends for player ${PLAYER_ID}`);
},
});
+
+Deno.test({
+ name: "live lookup: all friend mode is superset of mutual",
+ sanitizeOps: false,
+ sanitizeResources: false,
+ async fn() {
+ const [mutuals, allFriends] = await Promise.all([
+ fetchFriends(PLAYER_ID, "mutual", 100),
+ fetchFriends(PLAYER_ID, "all", 100),
+ ]);
+ assertGreaterOrEqual(allFriends.length, mutuals.length, "Expected union count >= mutual count");
+ const allIds = new Set(allFriends.map((f) => f.id));
+ for (const m of mutuals) {
+ assert(allIds.has(m.id), `Expected mutual id ${m.id} in all friend list`);
+ }
+ },
+});
diff --git a/src/client/overlay-config.ts b/src/client/overlay-config.ts
index b0905d3..71fee2b 100644
--- a/src/client/overlay-config.ts
+++ b/src/client/overlay-config.ts
@@ -21,7 +21,7 @@ export interface OverlayConfigApiBody {
defaults: Partial;
}
-const FRIEND_MODES = new Set(["mutual", "following", "followers"]);
+const FRIEND_MODES = new Set(["mutual", "following", "followers", "all"]);
/** Merge `/api/overlay-config` into the object used as `defaults` before applying the URL hash. */
export function mergeOverlayConfigResponse(
@@ -84,7 +84,7 @@ export function overlayTomlToDefaults(toml: OverlayToml): {
if (FRIEND_MODES.has(raw as FriendMode)) defaults.friendMode = raw as FriendMode;
else {
warnings.push(
- `overlay.toml: invalid friend_mode "${toml.friend_mode}" (expected mutual, following, or followers)`,
+ `overlay.toml: invalid friend_mode "${toml.friend_mode}" (expected mutual, following, followers, or all)`,
);
}
}
diff --git a/src/client/types.ts b/src/client/types.ts
index 02e4b8b..527036e 100644
--- a/src/client/types.ts
+++ b/src/client/types.ts
@@ -1,6 +1,6 @@
// https://github.com/hardcpp/BeatSaberPlus/wiki/%5BEN%5D-Song-Overlay
-export type FriendMode = "mutual" | "following" | "followers";
+export type FriendMode = "mutual" | "following" | "followers" | "all";
/** Overlay UI + BeatLeader id (URL hash overrides defaults from overlay.toml / `/api/overlay-config`). */
export interface OverlaySettings {