full joindate fix when theres no about

This commit is contained in:
murdle 2025-12-14 14:54:38 +02:00
parent 7483a6c357
commit 311d7f1960
3 changed files with 67 additions and 54 deletions

View File

@ -4,7 +4,7 @@
<h1 align="center">RSCord Server</h1> <h1 align="center">RSCord Server</h1>
## About ## About
This is based off spacebar, however this is not spacebar anymore because of the amount of changes done to the source code. This is based off Spacebar, however this is not Spacebar anymore because of the amount of changes done to the source code.
This repository contains: This repository contains:
@ -17,8 +17,7 @@ This repository contains:
## [Documentation](https://docs.spacebar.chat) ## [Documentation](https://docs.spacebar.chat)
And with documentation on how to set up your own server [here](https://docs.spacebar.chat/setup/server), and docs about bots [here](https://docs.spacebar.chat/setup/bots/) Documentation on how to set up your own server is [here](https://docs.spacebar.chat/setup/server), and docs about bots are [here](https://docs.spacebar.chat/setup/bots/)
## Clients ## Frontend
It's located at localhost:3001, the client date is July 2022. It also uses a custom client mod to add QoL features that were not present in the old Discord frontend.
It's located at localhost:3001, the client date is from the 1st of May 2021. There are more clients such as the patched up native one and the mobile one murdle made.

View File

@ -1,3 +1,9 @@
const CONFIG_KEY = "rscord_config";
const DEFAULT_CONFIG = { customCss: "", revertStatusIcons: false };
window.AUTH_TOKEN = null;
window.localStorage_ = localStorage;
function urlBase64ToUint8Array(base64String) { function urlBase64ToUint8Array(base64String) {
const padding = "=".repeat((4 - (base64String.length % 4)) % 4); const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
const base64 = (base64String + padding) const base64 = (base64String + padding)
@ -14,6 +20,24 @@ function urlBase64ToUint8Array(base64String) {
return outputArray; return outputArray;
} }
function loadConfig() {
try {
return {
...DEFAULT_CONFIG,
...JSON.parse(localStorage_.getItem(CONFIG_KEY) || "{}")
};
} catch {
return { ...DEFAULT_CONFIG };
}
}
function saveConfig(patch) {
const config = loadConfig();
const updated = { ...config, ...patch };
localStorage_.setItem(CONFIG_KEY, JSON.stringify(updated));
return updated;
}
let proxied = window.XMLHttpRequest.prototype.setRequestHeader; let proxied = window.XMLHttpRequest.prototype.setRequestHeader;
window.XMLHttpRequest.prototype.setRequestHeader = function() { window.XMLHttpRequest.prototype.setRequestHeader = function() {
if (arguments[0] === "Authorization") { if (arguments[0] === "Authorization") {
@ -44,12 +68,11 @@ window.CSS_CLASSES = {
userInfoBody: "userInfoBody-1zgAd0 markup-eYLPri clamped-2ZePhX", userInfoBody: "userInfoBody-1zgAd0 markup-eYLPri clamped-2ZePhX",
userInfoSectionHeader: "defaultColor-24IHKz eyebrow-Ejf06y defaultColor-HXu-5n userInfoSectionHeader-2mYYun", userInfoSectionHeader: "defaultColor-24IHKz eyebrow-Ejf06y defaultColor-HXu-5n userInfoSectionHeader-2mYYun",
userInfoText: "userInfoText-2MFCmH markup-eYLPri clamped-2ZePhX", userInfoText: "userInfoText-2MFCmH markup-eYLPri clamped-2ZePhX",
userInfoSection: "userInfoSection-3her-v",
title: "colorStandard-1Xxp1s size14-k_3Hy4 h1-34Txb0 title-3hptVQ defaultColor-2cKwKo defaultMarginh1-EURXsm", title: "colorStandard-1Xxp1s size14-k_3Hy4 h1-34Txb0 title-3hptVQ defaultColor-2cKwKo defaultMarginh1-EURXsm",
miniTitle: "colorStandard-1Xxp1s size14-k_3Hy4 h5-2RwDNl title-3hptVQ title-1HgbhV", miniTitle: "colorStandard-1Xxp1s size14-k_3Hy4 h5-2RwDNl title-3hptVQ title-1HgbhV",
hidden: "hidden-27eifz", hidden: "hidden-27eifz",
hamburger: "btnHamburger-3GF0_5", hamburger: "btnHamburger-3GF0_5",
textInput: "inputDefault-3FGxgL input-2g-os5" textInput: "inputDefault-3FGxgL input-2g-os5",
}; nitroBadge: ".clickable-1knRMS[aria-label]",
};
window.AUTH_TOKEN = null;
window.localStorage_ = localStorage;

View File

@ -5,9 +5,6 @@
const CUSTOM_CSS_ID = "custom-css"; const CUSTOM_CSS_ID = "custom-css";
const CUSTOM_CSS_INPUT_ID = "custom-css-input"; const CUSTOM_CSS_INPUT_ID = "custom-css-input";
const CONFIG_KEY = "rscord_config";
const DEFAULT_CONFIG = { customCss: "", revertStatusIcons: false };
const STATUS_COLOR_MAP = { const STATUS_COLOR_MAP = {
"hsl(38, calc(var(--saturation-factor, 1) * 95.7%), 54.1%)": "#FAA61A", // Idle (yellow) "hsl(38, calc(var(--saturation-factor, 1) * 95.7%), 54.1%)": "#FAA61A", // Idle (yellow)
@ -29,69 +26,63 @@
<textarea id="${CUSTOM_CSS_INPUT_ID}" class="${CSS_CLASSES.textInput}" placeholder="CSS goes here" type="text" name="" style="resize: vertical;height: 400px;"></textarea> <textarea id="${CUSTOM_CSS_INPUT_ID}" class="${CSS_CLASSES.textInput}" placeholder="CSS goes here" type="text" name="" style="resize: vertical;height: 400px;"></textarea>
`; `;
function loadConfig() {
try {
return {
...DEFAULT_CONFIG,
...JSON.parse(localStorage_.getItem(CONFIG_KEY) || "{}")
};
} catch {
return { ...DEFAULT_CONFIG };
}
}
function saveConfig(patch) {
const config = loadConfig();
const updated = { ...config, ...patch };
localStorage_.setItem(CONFIG_KEY, JSON.stringify(updated));
return updated;
}
// this is a shitty patch
// you can just grab this from the request but i do not care
function addJoinDates() { function addJoinDates() {
if (document.getElementById("join-date")) return; if (document.querySelector("[data-join-date]")) return;
const infoSection = document.querySelector(".userInfoSection-2u2hir > :has(+ .note-3M15gE)") const nitroBadge = document.querySelector(CSS_CLASSES.nitroBadge);
const firstBody = document.querySelector(".userInfoSection-3her-v > div"); const date = nitroBadge?.getAttribute("aria-label")?.replace("Subscriber since ", "");
if (!infoSection && !firstBody) return; if (!date) return;
const nitroBadge = document.querySelector(".clickable-1knRMS[aria-label]"); const isCompact = !!document.querySelector("h3.bodyTitle-2Az3VQ");
if (!nitroBadge) return; const anchor = [...document.querySelectorAll("h3")].find(h =>
(h.className.includes("bodyTitle") && h.textContent.includes("Role")) ||
const nitroText = nitroBadge.getAttribute("aria-label"); h.textContent.trim() === "Note"
if (!nitroText) return; );
if (!anchor) return;
const infoText = document.createElement("div"); const infoText = document.createElement("div");
infoText.id = "join-date"; infoText.className = isCompact ? CSS_CLASSES.userInfoTitle : CSS_CLASSES.userInfoSectionHeader;
infoText.className = infoSection ? CSS_CLASSES.userInfoSectionHeader : CSS_CLASSES.userInfoTitle;
infoText.textContent = "Member since"; infoText.textContent = "Member since";
infoText.style.color = "var(--header-secondary)"; infoText.style.color = "var(--header-secondary)";
infoText.style.marginTop = "10px"; infoText.dataset.joinDate = "title";
const dateText = document.createElement("div"); const dateText = document.createElement("div");
dateText.id = "join-date"; dateText.className = isCompact ? CSS_CLASSES.userInfoBody : CSS_CLASSES.userInfoText;
dateText.className = infoSection ? CSS_CLASSES.userInfoText : CSS_CLASSES.userInfoBody; dateText.textContent = date;
dateText.textContent = nitroText.replace("Subscriber since ", ""); dateText.dataset.joinDate = "value";
infoSection && infoSection.insertAdjacentElement("beforebegin", infoText); if (isCompact) {
firstBody && firstBody.insertAdjacentElement("afterend", infoText); let infoSection = anchor.previousElementSibling;
infoText.insertAdjacentElement("afterend", dateText); const isNewSection = !infoSection;
if (isNewSection) {
infoSection = document.createElement("div");
infoSection.className = CSS_CLASSES.userInfoSection;
anchor.parentNode.insertBefore(infoSection, anchor);
}
infoText.style.marginTop = isNewSection ? "0px" : "5px";
infoSection.append(infoText, dateText);
} else {
anchor.parentNode.insertBefore(infoText, anchor);
anchor.parentNode.insertBefore(dateText, anchor);
}
} }
async function addSwitches(container) { async function addSwitches(container) {
const config = loadConfig(); const config = loadConfig();
const pushRegistered = await isPushRegistered();
container.appendChild(createSwitch( container.appendChild(createSwitch(
"Push Notifications", "Push Notifications",
"Sends you notifications even when you close the app", "Sends you notifications even when you close the app",
"push-notifications", "push-notifications",
await isPushRegistered(), pushRegistered,
async (checked) => { async (checked) => {
const publicKey = window.GLOBAL_ENV.VAPID_KEY; const publicKey = window.GLOBAL_ENV.VAPID_KEY;
if (!publicKey) return false; if (!publicKey) return false;
try { try {
checked ? await registerPush(publicKey) : await unregisterPush(); await (checked ? registerPush(publicKey) : unregisterPush());
return true; return true;
} catch { } catch {
return false; return false;