From e23fa02c91efe792b6e0bf9e3ca37a35fc236e17 Mon Sep 17 00:00:00 2001 From: 3urobeat <35304405+HerrEurobeat@users.noreply.github.com> Date: Sun, 28 May 2023 14:02:40 +0200 Subject: [PATCH] Add support for reading numRatings of guides --- classes/CSteamSharedfile.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/CSteamSharedfile.js b/classes/CSteamSharedfile.js index 6935787..2523b48 100644 --- a/classes/CSteamSharedfile.js +++ b/classes/CSteamSharedfile.js @@ -24,6 +24,7 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) { uniqueVisitorsCount: null, favoritesCount: null, upvoteCount: null, + guideNumRatings: null, isUpvoted: null, isDownvoted: null }; @@ -105,6 +106,12 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) { } + // Find numRatings if this is a guide as they use a different voting system + let numRatings = $(".ratingSection > .numRatings").text().replace(" ratings", "") + + sharedfile.guideNumRatings = Number(numRatings) || null; // Set to null if not a guide or if the guide does not have enough ratings to show a value + + // Determine if this account has already voted on this sharedfile sharedfile.isUpvoted = String($(".workshopItemControlCtn > #VoteUpBtn")[0].attribs["class"]).includes("toggled"); // Check if upvote btn class contains "toggled" sharedfile.isDownvoted = String($(".workshopItemControlCtn > #VoteDownBtn")[0].attribs["class"]).includes("toggled"); // Check if downvote btn class contains "toggled"