Skip to content

Game statistics guide

Wesley Pyburn (TechNobo) edited this page Jul 20, 2022 · 1 revision

How the game stat template system works

Since July 2022 (Version 6.0) the latest huge addition was game statistics tracking. You can now grab data from different web pages and have them show on your account. Say Apex Legends; you can pull your level and rank from <website>.com/<steamid> and have them display in-app under your account! It's a great feature, but as it's web scraping I do reach out to websites I use in-app before publically including them.

That being said, you can happily include your own game or stats for any game by editing one text file; GameStats.json. If you do make changes, please contact me so I can reach out to the website hosts (if not you) to include all users. More details on editing the JSON file can be found in this Wiki article.

Main layout

In the StatsDefinitions object, there are multiple game objects. The platform object's key is the game's name. For example, "Apex Legends".

Inside the Platform object, there are required keys and optional keys.

There is also a PlatformCompatibilities object that tells the account switcher what game from StatsDefinitions to include on which platform/s.

Details

  • UniqueId (String): This is a simple, unique, short string with no special characters to represent the game name.
  • Indicator (String): This shows up just before a stat under an account (Incase X and Y games both have "LVL" stats). This should be short and simple once again but may include special characters. These should be short as they are displayed as KEY <data>, as in LVL 17. If the indicator is not blank, it will display as INDICATOR KEY <data>, as in APEX LVL 17. The indicator text is displayed as a superscript using the HTML <sup> tag.
  • Url (String): This is the main URL to get information from. You can substitute in Vars collected from users by adding say {Username} and defining it later.
  • RequestCookies (String): Any special cookies that may be required to GET from the URL above.
  • Vars (Object): Each key is a variable name to be used in Url above. The value is a placeholder prompt for the user to understand what is asked for. Both should be simple to read, as both are displayed in the modal. For example "Username": "Origin username" shows as Username [Origin username_______] in the GUI (the brackets being a text input field).
    • This can include special variables. Using %ACCOUNTID% grabs the ID for whatever account is currently open. This is limited for now, but more automatic variables can be added in the future.
  • Collect (Object): Each key in Object is the name of a stat to show in the switcher. Each key needs some settings inside it, as follows:
    • XPath (XPath String): XPath is a simple string that points the software to an element in HTML. If you've ever used JQuery's $("selector"), you likely understand how this works. It's relatively simple, and Selenium have a great guide. The less specific and more accurate you make yours, the more likely it will last through small website changes. For example; prefer .//*[@class='levelNumber'] over /HTML/body/div/div/div/div[1]/span/div/....
    • Select (String): What to select from the element found using XPath. This can be innerText or innerHtml depending on your use case. This can also be attribute, but make sure to set SelectAttribute.
    • SelectAttribute (String): Optional. The type of attribute to collect if Select is set to attribute. This can be set to src for an image link, for example.
    • SpecialType (String): This has very limited uses currently. If you add "SpecialType": "ImageDownload", it will attempt to download the attribute value as a file and use it as an image.
    • DisplayAs (String): Simple text to display under accounts. Use %x% for the data collected. Do keep in mind these will display just after the <sup>{Indicator}</sup> set above. Once again: keep it short. This can be just %x% and nothing more. HTML can also be used, for example: Use <img src=\"%x%\" /> if the "stat" you're collecting is an image.
    • NoDisplayIf (String): If the DisplayAs text after substitution is the same as this, it won't be displayed. For example: Lvl 0 set here will not show anything if the requested account is Level 0.
    • ToggleText (String): This is used in the modal. Users can toggle on/off specific stats from showing on their accounts. Speaking of, they can also disable specific stats for games globally in the platform's settings - So no "Wins" counter shows, for example. It is downloaded and placed in wwwroot\\img\\statsCache.

API support should be coming at some stage in the future. Essentially you'll swap out XPath for maybe APIPath or something... I will probably use something similar, maybe even XPath? Then you should be able to collect specific stats from an API response easily. All you'd need to do is swap out the URL for an API URL instead.