Skip to content

Commit

Permalink
Merge pull request IsThereAnyDeal#1845 from candela97/fix-profileedit…
Browse files Browse the repository at this point in the history
…page-features2

Fix profile edit page features not showing up
  • Loading branch information
tfedor authored Mar 11, 2024
2 parents 3797bbc + 7c6dec7 commit ebbcea7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
17 changes: 0 additions & 17 deletions src/js/Content/Features/Community/ProfileEdit/CProfileEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ export class CProfileEdit extends CCommunityBase {
this.data = this.profileDataPromise().catch(err => console.error(err));
}

async applyFeatures() {

const root = document.getElementById("react_root");
if (root && !root.querySelector('[class^="profileeditshell_PageContent_"]')) {
await new Promise(resolve => {
new MutationObserver((_, observer) => {
if (root.querySelector('[class^="profileeditshell_PageContent_"]') !== null) {
observer.disconnect();
resolve();
}
}).observe(root, {"childList": true});
});
}

return super.applyFeatures();
}

profileDataPromise() {
return Background.action("profile", this.steamId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ export default class FBackgroundSelection extends Feature {
apply() {

this._active = false;
this._root = document.querySelector("#react_root");

this._checkPage();

new MutationObserver(() => { this._checkPage(); })
.observe(document.querySelector('[class^="profileeditshell_PageContent_"]'), {"childList": true});
.observe(this._root, {"childList": true, "subtree": true});
}

async _checkPage() {
Expand Down Expand Up @@ -59,7 +60,7 @@ export default class FBackgroundSelection extends Feature {

if (this._active) { return; } // Happens because the below code will trigger the observer again

HTML.beforeEnd('[class^="profileeditshell_PageContent_"]', html);
HTML.beforeEnd(this._root.querySelector(":scope > div:last-child > div:last-child"), html);
this._active = true;

const gameFilterNode = document.querySelector(".js-pd-game");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export default class FStyleSelection extends Feature {
apply() {

this._active = false;
this._root = document.querySelector("#react_root");

this._checkPage();

new MutationObserver(() => { this._checkPage(); })
.observe(document.querySelector('[class^="profileeditshell_PageContent_"]'), {"childList": true});
.observe(this._root, {"childList": true, "subtree": true});
}

_checkPage() {
Expand Down Expand Up @@ -64,7 +65,7 @@ export default class FStyleSelection extends Feature {

if (this._active) { return; } // Happens because the below code will trigger the observer again

HTML.beforeEnd('[class^="profileeditshell_PageContent_"]', html);
HTML.beforeEnd(this._root.querySelector(":scope > div:last-child > div:last-child"), html);
this._active = true;

const styleSelectNode = document.querySelector(".js-pd-style-select");
Expand Down

0 comments on commit ebbcea7

Please sign in to comment.