-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added protondb ratings to hover boxes (#8)
- Loading branch information
Showing
9 changed files
with
85 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {createElement, getProtonDBRating, upperCase} from "./utils/utils"; | ||
|
||
/** | ||
* Adds rating text to the hover box | ||
*/ | ||
export function checkHover() { | ||
const hoverDiv = document.getElementById('global_hover_content'); | ||
const mutationObserver = new window.MutationObserver(() => { | ||
if (!hoverDiv) return | ||
const games = hoverDiv.children; | ||
for (const game of games) { | ||
if (!game.id.startsWith('hover_app_')) continue; | ||
const reviews = game.getElementsByClassName('hover_review_summary')[0] | ||
const hasRating = reviews.getElementsByClassName('protonfox-rating-bright').length !== 0; | ||
if (!hasRating) { | ||
const gameId = game.id.substring('hover_app_'.length); | ||
getProtonDBRating(gameId).then(async (rating) => { | ||
const protonDBRatingTitle = createElement('ProtonDB rating: ', ['title'], 'div'); | ||
protonDBRatingTitle.appendChild(createElement(upperCase(rating), [`protonfox-rating-${rating}`, 'protonfox-rating-bright'])) | ||
reviews.prepend(protonDBRatingTitle) | ||
}) | ||
} | ||
} | ||
}); | ||
if (hoverDiv) { | ||
mutationObserver.observe(hoverDiv, {childList: true}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters