AAAAAAAAAAAAAAA

This commit is contained in:
Clove 2026-06-26 02:56:13 +01:00
parent e03f14e959
commit 5e60cc91e8
1 changed files with 33 additions and 15 deletions

View File

@ -305,22 +305,38 @@
return html; return html;
} }
// Richer badges via dstn.to — Nitro, boosts, quests, orbs… everything // Rich Discord badges (Nitro, boosts, quests, orbs… everything Discord
// Discord actually shows, which public_flags (0 for most) can't give. // actually shows, which public_flags alone can't give) — resolved
let dstnBadges = null; // server-side by the Doughmination Restful API, same source as the rest
// of the profile data.
let doughBadges = null;
// Third-party client-mod badges (Vencord/Equicord/Aliucord/etc, via the
// worker's data.clientBadges — separate from Discord's own badges above).
let clientBadges = null;
let lastFlags = 0; let lastFlags = 0;
function renderDstnBadges() { function renderDoughBadges() {
return dstnBadges.map(function (b) { return doughBadges.map(function (b) {
const img = '<img class="pc-badge" src="' + proxyImg("https://cdn.discordapp.com/badge-icons/" + esc(b.icon) + ".png") + const img = '<img class="pc-badge" data-badge-id="' + esc(b.id) + '" src="' + proxyImg("https://cdn.discordapp.com/badge-icons/" + esc(b.icon) + ".png") +
'" alt="' + esc(b.description || b.id) + '" title="' + esc(b.description || b.id) + '" onerror="this.remove()">'; '" alt="' + esc(b.description || b.id) + '" title="' + esc(b.description || b.id) + '" onerror="this.remove()">';
return b.link return b.link
? '<a class="pc-badge-link" tabindex="-1" href="' + esc(b.link) + '" target="_blank" rel="noopener">' + img + "</a>" ? '<a class="pc-badge-link" tabindex="-1" href="' + esc(b.link) + '" target="_blank" rel="noopener">' + img + "</a>"
: img; : img;
}).join(""); }).join("");
} }
// These come from an unofficial third-party aggregator (not Discord
// itself), so they're rendered in their own pass with their own class
// (.pc-badge--client) rather than mixed indistinguishably into the
// regular badge markup.
function renderClientBadges() {
if (!clientBadges || !clientBadges.length) return "";
return clientBadges.map(function (b) {
return '<img class="pc-badge pc-badge--client" data-badge-id="' + esc(b.id) + '" src="' + esc(b.icon_url) +
'" alt="' + esc(b.tooltip || "") + '" title="' + esc(b.tooltip || "") + '" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">';
}).join("");
}
function paintBadges() { function paintBadges() {
if (!badgesEl) return; if (!badgesEl) return;
badgesEl.innerHTML = (dstnBadges && dstnBadges.length) ? renderDstnBadges() : renderBadges(lastFlags); badgesEl.innerHTML = (doughBadges && doughBadges.length ? renderDoughBadges() : renderBadges(lastFlags)) + renderClientBadges();
} }
function rgbTriplet(n) { function rgbTriplet(n) {
n = Number(n) >>> 0; n = Number(n) >>> 0;
@ -749,8 +765,8 @@
const SELF_POLL_MS = opts.pollMs || 20000; // presence refresh cadence const SELF_POLL_MS = opts.pollMs || 20000; // presence refresh cadence
let selfTimer = null; let selfTimer = null;
// self-host shape -> the Lanyard-shaped object render() already understands // self-host shape -> the presence-shaped object render() already understands
function mapSelfHostToLanyard(j) { function mapSelfHostToPresence(j) {
const u = (j.data && j.data.user) || {}; const u = (j.data && j.data.user) || {};
const p = (j.data && j.data.presence) || {}; const p = (j.data && j.data.presence) || {};
const plat = p.platform || {}; const plat = p.platform || {};
@ -785,14 +801,16 @@
function renderFromSelfHost(j) { function renderFromSelfHost(j) {
const u = (j.data && j.data.user) || {}; const u = (j.data && j.data.user) || {};
render(mapSelfHostToLanyard(j)); render(mapSelfHostToPresence(j));
// badges arrive pre-resolved (same consumer as dstn badges) // badges arrive pre-resolved straight from the Doughmination Restful API
if (Array.isArray(j.data.badges) && j.data.badges.length) { if (Array.isArray(j.data.badges) && j.data.badges.length) {
dstnBadges = j.data.badges; doughBadges = j.data.badges;
paintBadges();
} }
// Nitro profile gradient — straight from the self-hosted API now that it // Third-party client-mod badges (Vencord/Equicord/Aliucord/etc); kept
// returns theme_colors (previously only the dstn.to fallback applied this) // separate from doughBadges since it's a different, unofficial source.
clientBadges = Array.isArray(j.data.clientBadges) ? j.data.clientBadges : null;
paintBadges();
// Nitro profile gradient — straight from the self-hosted API
if (Array.isArray(u.theme_colors)) applyProfileGradient(u.theme_colors); if (Array.isArray(u.theme_colors)) applyProfileGradient(u.theme_colors);
// profile extras: banner rebuilt from the raw hash (dodges the animated // profile extras: banner rebuilt from the raw hash (dodges the animated
// .gif 415), plus bio / connections / pronouns straight from the API // .gif 415), plus bio / connections / pronouns straight from the API