Skip to content

Commit

Permalink
Fix root node for detecting whether page has loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
candela97 committed Jan 30, 2024
1 parent c5f4cd5 commit cdec580
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/js/Content/Features/Community/ProfileEdit/CProfileEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ export class CProfileEdit extends CCommunityBase {

async applyFeatures() {

if (!document.querySelector('[class^="profileeditshell_PageContent_"]')) {
const root = document.getElementById("react_root");
if (root && !root.querySelector('[class^="profileeditshell_PageContent_"]')) {
await new Promise(resolve => {
new MutationObserver((records, observer) => {
for (const {addedNodes} of records) {
for (const node of addedNodes) {
if (node.nodeType !== Node.ELEMENT_NODE
|| !node.querySelector('[class^="profileeditshell_PageContent_"]')) { continue; }

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

Expand Down

0 comments on commit cdec580

Please sign in to comment.