Skip to content

Commit

Permalink
fix: Rename chess.com css class (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
thieleju committed Sep 25, 2024
1 parent 3f3d7a1 commit 447bcaa
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/modules/UiUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ export class UiUpdater {
htmlEl.dataset.tooltipTarget = "15"
htmlEl.innerHTML = specialTitle

// remove chess.com diamond badge if present
// class mvp-badge-component
const diamondBadge: HTMLElement | null | undefined = this.getPlayerElement(
side
)?.parentElement?.querySelector(".mvp-badge-component")

if (diamondBadge) diamondBadge.style.display = "none"

this.getPlayerElement(side)?.parentElement?.prepend(htmlEl)
}

Expand Down Expand Up @@ -151,7 +159,9 @@ export class UiUpdater {
*/
private createTooltip(stats: Stats, timeInterval: string): HTMLElement {
const tooltip: HTMLElement = document.createElement("div")
// History of chess.com's class names for tooltips
tooltip.classList.add(
"user-popover-content",
"user-popover-legacy-component",
"user-popover-legacy-popover",
"user-username-component",
Expand All @@ -164,11 +174,13 @@ export class UiUpdater {
stats.accuracy.avg === 0
? `<span style="padding-bottom:5px"> \
No accuracy data available (${timeInterval}) \
<br>\
<br> \
<br> \
Accuracy is only available on analyzed games \
</span>`
: `<span style="padding-bottom:5px"> \
<strong>Average accuracy of ${stats.accuracy.avg}%</strong> (${timeInterval}) \
<br> \
</span> \
<span> \
Accuracy based on ${games} out of ${stats.wld.games} games \
Expand All @@ -180,6 +192,8 @@ export class UiUpdater {
tooltip.style.padding = "10px"
tooltip.style.width = `auto`
tooltip.style.maxWidth = `fit-content`
tooltip.style.backgroundColor = "var(--color-bg-opaque)"
tooltip.style.color = "var(--color-text-subtle)"

return tooltip
}
Expand Down

0 comments on commit 447bcaa

Please sign in to comment.