From fb6ba088bfeb0baabcc700b5feb770f409718337 Mon Sep 17 00:00:00 2001 From: candela97 <54083835+candela97@users.noreply.github.com> Date: Fri, 15 Mar 2024 06:09:58 +0800 Subject: [PATCH 1/2] Tweaks to FShowHiddenAchievements, disable FAchievementSort --- .../Community/ProfileStats/CProfileStats.js | 25 +---------- .../ProfileStats/FShowHiddenAchievements.js | 45 +++++++++++++------ 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/js/Content/Features/Community/ProfileStats/CProfileStats.js b/src/js/Content/Features/Community/ProfileStats/CProfileStats.js index b5f58e5b0..de8c5226c 100644 --- a/src/js/Content/Features/Community/ProfileStats/CProfileStats.js +++ b/src/js/Content/Features/Community/ProfileStats/CProfileStats.js @@ -1,5 +1,4 @@ -import {GameId, HTMLParser, Language} from "../../../../modulesCore"; -import {ContextType, RequestData, User} from "../../../modulesContent"; +import {ContextType} from "../../../modulesContent"; import {CCommunityBase} from "../CCommunityBase"; import FAchievementSort from "./FAchievementSort"; import FShowHiddenAchievements from "./FShowHiddenAchievements"; @@ -15,28 +14,8 @@ export class CProfileStats extends CCommunityBase { } super(ContextType.PROFILE_STATS, [ - FAchievementSort, + // FAchievementSort, FShowHiddenAchievements, ]); - - this.appid = GameId.getAppidImgSrc( - document.querySelector(".gameLogo img")?.getAttribute("src") - ); - } - - async getAchievementData() { - if (this._data) { return this._data; } - - const params = new URLSearchParams(); - params.set("format", "json"); - params.set("access_token", await User.accessToken); - params.set("appid", this.appid); - params.set("language", Language.getCurrentSteamLanguage()); - params.set("x_requested_with", "AugmentedSteam"); - - return RequestData.getJson( - `https://api.steampowered.com/IPlayerService/GetGameAchievements/v1/?${params.toString()}`, - {"credentials": "omit"} - ); } } diff --git a/src/js/Content/Features/Community/ProfileStats/FShowHiddenAchievements.js b/src/js/Content/Features/Community/ProfileStats/FShowHiddenAchievements.js index b8fa3b658..2218e1bf6 100644 --- a/src/js/Content/Features/Community/ProfileStats/FShowHiddenAchievements.js +++ b/src/js/Content/Features/Community/ProfileStats/FShowHiddenAchievements.js @@ -1,5 +1,5 @@ -import {HTML, Localization} from "../../../../modulesCore"; -import {Feature} from "../../../modulesContent"; +import {GameId, HTML, Language, Localization} from "../../../../modulesCore"; +import {Feature, RequestData, User} from "../../../modulesContent"; export default class FShowHiddenAchievements extends Feature { @@ -11,6 +11,11 @@ export default class FShowHiddenAchievements extends Feature { apply() { + const appid = GameId.getAppidImgSrc( + document.querySelector(".gameLogo img")?.getAttribute("src") + ); + if (!appid) { return; } + const parent = this._node.parentNode; HTML.afterEnd(parent.querySelector(".achieveTxt"), @@ -20,20 +25,19 @@ export default class FShowHiddenAchievements extends Feature { const btn = document.getElementById("as_ach_showall"); btn.addEventListener("click", async() => { - if (btn.classList.contains("btn_disabled")) - return; + if (btn.classList.contains("btn_disabled")) { return; } - let visibleAchievements = [...document.querySelectorAll(".achieveTxt")].map(x => { + const visibleAchievements = [...document.querySelectorAll(".achieveTxt")].map(x => { return { - name: x.querySelector("h3").innerHTML, - desc: x.querySelector("h5").innerHTML, - } + name: x.querySelector("h3").textContent, + desc: x.querySelector("h5").textContent, + }; }); - let achievements = await this.context.getAchievementData(); - achievements = Object.values({...achievements.response.achievements}).filter(val => - val.hidden && !visibleAchievements.some(x => - x.name === val.localized_name && x.desc === val.localized_desc + let achievements = await this._getAchievements(appid); + achievements = Object.values({...achievements.response.achievements}).filter( + val => val.hidden && !visibleAchievements.some( + x => x.name === val.localized_name && x.desc === val.localized_desc ) ); @@ -41,7 +45,7 @@ export default class FShowHiddenAchievements extends Feature { HTML.afterEnd(parent, `
- +
@@ -55,4 +59,19 @@ export default class FShowHiddenAchievements extends Feature { btn.classList.add("btn_disabled"); }); } + + async _getAchievements(appid) { + + const params = new URLSearchParams(); + params.set("format", "json"); + params.set("access_token", await User.accessToken); + params.set("appid", appid); + params.set("language", Language.getCurrentSteamLanguage()); + params.set("x_requested_with", "AugmentedSteam"); + + return RequestData.getJson( + `https://api.steampowered.com/IPlayerService/GetGameAchievements/v1/?${params.toString()}`, + {"credentials": "omit"} + ); + } } From 9e0ad68c3fe3179478920de962771fdf67589e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Fedor?= Date: Sun, 17 Mar 2024 03:19:09 +0100 Subject: [PATCH 2/2] Update CProfileStats.js Do not disable FAchievementSort --- src/js/Content/Features/Community/ProfileStats/CProfileStats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/Content/Features/Community/ProfileStats/CProfileStats.js b/src/js/Content/Features/Community/ProfileStats/CProfileStats.js index de8c5226c..2a22a3bca 100644 --- a/src/js/Content/Features/Community/ProfileStats/CProfileStats.js +++ b/src/js/Content/Features/Community/ProfileStats/CProfileStats.js @@ -14,7 +14,7 @@ export class CProfileStats extends CCommunityBase { } super(ContextType.PROFILE_STATS, [ - // FAchievementSort, + FAchievementSort, FShowHiddenAchievements, ]); }