diff --git a/src/js/Content/Features/Community/ProfileEdit/CProfileEdit.js b/src/js/Content/Features/Community/ProfileEdit/CProfileEdit.js index 7ccb4c17a..e5f8606e6 100644 --- a/src/js/Content/Features/Community/ProfileEdit/CProfileEdit.js +++ b/src/js/Content/Features/Community/ProfileEdit/CProfileEdit.js @@ -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); } diff --git a/src/js/Content/Features/Community/ProfileEdit/FBackgroundSelection.js b/src/js/Content/Features/Community/ProfileEdit/FBackgroundSelection.js index 8184eca0b..d9db5e20e 100644 --- a/src/js/Content/Features/Community/ProfileEdit/FBackgroundSelection.js +++ b/src/js/Content/Features/Community/ProfileEdit/FBackgroundSelection.js @@ -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() { @@ -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"); diff --git a/src/js/Content/Features/Community/ProfileEdit/FStyleSelection.js b/src/js/Content/Features/Community/ProfileEdit/FStyleSelection.js index 601c97d38..40c98ab3c 100644 --- a/src/js/Content/Features/Community/ProfileEdit/FStyleSelection.js +++ b/src/js/Content/Features/Community/ProfileEdit/FStyleSelection.js @@ -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() { @@ -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");