Skip to content

Commit

Permalink
Tweaks to FShowHiddenAchievements, disable FAchievementSort
Browse files Browse the repository at this point in the history
  • Loading branch information
candela97 committed Mar 14, 2024
1 parent c97941d commit d31db9a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 38 deletions.
25 changes: 2 additions & 23 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 @@ -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"}
);
}
}
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,26 @@ 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 +58,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 d31db9a

Please sign in to comment.