Skip to content

Commit

Permalink
feat: support for games with no rating (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxgic1337 authored Jan 8, 2025
1 parent 279358e commit b1f9750
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 9 deletions.
Binary file added .github/assets/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Protonfox
Protonfox is an extension for [Firefox](https://firefox.com) that displays ProtonDB ratings on Steam.
Protonfox is an extension for [Firefox](https://firefox.com) that displays [ProtonDB](https://protondb.com) ratings on Steam.

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mxgic1337/protonfox/build-check.yml?style=flat-square) ![GitHub package.json version](https://img.shields.io/github/package-json/v/mxgic1337/protonfox?style=flat-square)

![preview.png](.github/assets/preview.png)

# Building:
Requirements:
Expand All @@ -11,4 +15,6 @@ Requirements:
To build the extension:
- Run `pnpm install` to install dependencies.
- Run `pnpm run build` to build the extension.
- Run `pnpm run build` to build the extension.

This extension is not affiliated with ProtonDB and/or Valve Corporation.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "protonfox",
"version": "0.1.0",
"version": "0.2.0",
"description": "Displays information about game compatibility with Proton on Steam.",
"main": "index.js",
"type": "module",
"scripts": {
"build": "webpack --mode production && cp src/manifest.json dist/"
"build": "webpack --mode production && node scripts/manifest.cjs"
},
"keywords": [],
"author": "mxgic1337_",
Expand Down
13 changes: 13 additions & 0 deletions scripts/manifest.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('node:fs')
const path = require('path')

const packageJsonContent = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString())

const manifestPath = path.join(__dirname, '..', 'src', 'manifest.json')
const manifestDistPath = path.join(__dirname, '..', 'dist', 'manifest.json')

let manifestContent = fs.readFileSync(manifestPath).toString();
manifestContent = manifestContent.replaceAll('{{ version }}', packageJsonContent.version);
manifestContent = manifestContent.replaceAll('{{ description }}', packageJsonContent.description);

fs.writeFileSync(manifestDistPath, manifestContent)
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 2,
"name": "Protonfox",
"version": "0.1.0",
"description": "Displays information about game compatibility with Proton on Steam.",
"version": "{{ version }}",
"description": "{{ description }}",
"content_scripts": [
{
"matches": [
Expand Down
11 changes: 8 additions & 3 deletions src/steam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ function getGameID() {

const gameId = getGameID();
fetch(`https://www.protondb.com/api/v1/reports/summaries/${gameId}.json`).then(async (res) => {
const json = await res.json() as ProtonDBSummary;
addStoreRatingBadge(gameId, json.tier)
addSystemRequirementsRating(gameId, json.tier)
if (res.ok) {
const json = await res.json() as ProtonDBSummary;
addStoreRatingBadge(gameId, json.tier)
addSystemRequirementsRating(gameId, json.tier)
}else{
addStoreRatingBadge(gameId, ProtonDBRating.PENDING)
addSystemRequirementsRating(gameId, ProtonDBRating.PENDING)
}

let native = false;
for (const tab of document.getElementsByClassName('sysreq_tab')) {
Expand Down
2 changes: 2 additions & 0 deletions src/styles/steam.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@native: rgb(142, 214, 41);
@pending: rgb(187, 187, 187);
@platinum: rgb(180, 199, 220);
@gold: rgb(207, 181, 59);
@silver: rgb(166, 166, 166);
Expand Down Expand Up @@ -33,6 +34,7 @@
}

.native { .rating(@native) }
.pending { .rating(@pending) }
.platinum { .rating(@platinum) }
.gold { .rating(@gold) }
.silver { .rating(@silver) }
Expand Down
1 change: 1 addition & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum ProtonDBRating {
SILVER = 'silver',
BRONZE = 'bronze',
BORKED = 'borked',
PENDING = 'pending',
}

export interface ProtonDBSummary {
Expand Down

0 comments on commit b1f9750

Please sign in to comment.