Add support for determining up/downvote status

This commit is contained in:
3urobeat 2023-05-28 13:45:00 +02:00
parent f96d25ad52
commit 33bc8d83c9
No known key found for this signature in database
GPG Key ID: 6842D80775A4E952

View File

@ -23,7 +23,9 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) {
resolution: null,
uniqueVisitorsCount: null,
favoritesCount: null,
upvoteCount: null
upvoteCount: null,
isUpvoted: null,
isDownvoted: null
};
@ -103,6 +105,11 @@ SteamCommunity.prototype.getSteamSharedfile = function(sharedFileId, callback) {
}
// 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"
// Determine type by looking at the second breadcrumb. Find the first separator as it has a unique name and go to the next element which holds our value of interest
let breadcrumb = $(".breadcrumbs > .breadcrumb_separator").next().get(0).children[0].data || "";