Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tfedor committed Mar 17, 2024
2 parents 61b730f + 859f7f6 commit 51d0964
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
23 changes: 1 addition & 22 deletions src/js/Content/Features/Community/ProfileStats/CProfileStats.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -18,25 +17,5 @@ export class CProfileStats extends CCommunityBase {
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"}
);
}
}
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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"),
Expand All @@ -20,28 +25,27 @@ 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
)
);

for (const ach of achievements) {
HTML.afterEnd(parent,
`<div class="achieveRow">
<div class="achieveImgHolder">
<img src="//cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/${this.context.appid}/${ach.icon}">
<img src="//cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/${appid}/${ach.icon}">
</div>
<div class="achieveTxtHolder">
<div class="achieveTxt">
Expand All @@ -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"}
);
}
}

0 comments on commit 51d0964

Please sign in to comment.