AAAAAAAAAAAAAAA
This commit is contained in:
parent
e03f14e959
commit
5e60cc91e8
|
|
@ -305,22 +305,38 @@
|
|||
return html;
|
||||
}
|
||||
|
||||
// Richer badges via dstn.to — Nitro, boosts, quests, orbs… everything
|
||||
// Discord actually shows, which public_flags (0 for most) can't give.
|
||||
let dstnBadges = null;
|
||||
// Rich Discord badges (Nitro, boosts, quests, orbs… everything Discord
|
||||
// actually shows, which public_flags alone can't give) — resolved
|
||||
// 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;
|
||||
function renderDstnBadges() {
|
||||
return dstnBadges.map(function (b) {
|
||||
const img = '<img class="pc-badge" src="' + proxyImg("https://cdn.discordapp.com/badge-icons/" + esc(b.icon) + ".png") +
|
||||
function renderDoughBadges() {
|
||||
return doughBadges.map(function (b) {
|
||||
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()">';
|
||||
return b.link
|
||||
? '<a class="pc-badge-link" tabindex="-1" href="' + esc(b.link) + '" target="_blank" rel="noopener">' + img + "</a>"
|
||||
: img;
|
||||
}).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() {
|
||||
if (!badgesEl) return;
|
||||
badgesEl.innerHTML = (dstnBadges && dstnBadges.length) ? renderDstnBadges() : renderBadges(lastFlags);
|
||||
badgesEl.innerHTML = (doughBadges && doughBadges.length ? renderDoughBadges() : renderBadges(lastFlags)) + renderClientBadges();
|
||||
}
|
||||
function rgbTriplet(n) {
|
||||
n = Number(n) >>> 0;
|
||||
|
|
@ -749,8 +765,8 @@
|
|||
const SELF_POLL_MS = opts.pollMs || 20000; // presence refresh cadence
|
||||
let selfTimer = null;
|
||||
|
||||
// self-host shape -> the Lanyard-shaped object render() already understands
|
||||
function mapSelfHostToLanyard(j) {
|
||||
// self-host shape -> the presence-shaped object render() already understands
|
||||
function mapSelfHostToPresence(j) {
|
||||
const u = (j.data && j.data.user) || {};
|
||||
const p = (j.data && j.data.presence) || {};
|
||||
const plat = p.platform || {};
|
||||
|
|
@ -785,14 +801,16 @@
|
|||
|
||||
function renderFromSelfHost(j) {
|
||||
const u = (j.data && j.data.user) || {};
|
||||
render(mapSelfHostToLanyard(j));
|
||||
// badges arrive pre-resolved (same consumer as dstn badges)
|
||||
render(mapSelfHostToPresence(j));
|
||||
// badges arrive pre-resolved straight from the Doughmination Restful API
|
||||
if (Array.isArray(j.data.badges) && j.data.badges.length) {
|
||||
dstnBadges = j.data.badges;
|
||||
paintBadges();
|
||||
doughBadges = j.data.badges;
|
||||
}
|
||||
// Nitro profile gradient — straight from the self-hosted API now that it
|
||||
// returns theme_colors (previously only the dstn.to fallback applied this)
|
||||
// Third-party client-mod badges (Vencord/Equicord/Aliucord/etc); kept
|
||||
// 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);
|
||||
// profile extras: banner rebuilt from the raw hash (dodges the animated
|
||||
// .gif 415), plus bio / connections / pronouns straight from the API
|
||||
|
|
|
|||
Loading…
Reference in New Issue