From 7fd208f4fb5380db3c44269095668e90f51251d3 Mon Sep 17 00:00:00 2001 From: blankdvth Date: Mon, 22 Dec 2025 04:39:45 -0500 Subject: [PATCH 1/2] fix: failure to add config button --- src/EGO Forum Enhancement.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/EGO Forum Enhancement.ts b/src/EGO Forum Enhancement.ts index f79c05d..5605d12 100644 --- a/src/EGO Forum Enhancement.ts +++ b/src/EGO Forum Enhancement.ts @@ -1,7 +1,7 @@ // ==UserScript== // @name EdgeGamers Forum Enhancement%RELEASE_TYPE% // @namespace https://github.com/blankdvth/eGOScripts/blob/master/src/EGO%20Forum%20Enhancement.ts -// @version 4.11.5 +// @version 4.11.6 // @description Add various enhancements & QOL additions to the EdgeGamers Forums that are beneficial for Leadership members. // @author blank_dvth, Skle, MSWS, PixeL // @match https://www.edgegamers.com/* @@ -630,12 +630,13 @@ function setupForumsConfig() { const profileMenu = document.querySelector("div.js-visitorMenuBody"); if (profileMenu) { - const profileMenuObserver = new MutationObserver((mutations) => { - mutations.every((mutation) => { - mutation.addedNodes.forEach((node) => { - handleProfileDropdown(node as HTMLElement); - }); - }); + const profileMenuObserver = new MutationObserver(() => { + // Manually performing querySelector here due to odd failure to identify added node by MutationObserver + const target = profileMenu.querySelector("ul.tabPanes"); + if (target) { + handleProfileDropdown(target as HTMLElement); + profileMenuObserver.disconnect(); + } }); profileMenuObserver.observe(profileMenu, { childList: true, From 5733b9b8e37a69be37fb573c41d3afca59fd48a1 Mon Sep 17 00:00:00 2001 From: blankdvth Date: Mon, 22 Dec 2025 04:59:05 -0500 Subject: [PATCH 2/2] fix: failure to add config button for non-forum-mods --- src/EGO Forum Enhancement.ts | 48 +++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/EGO Forum Enhancement.ts b/src/EGO Forum Enhancement.ts index 5605d12..51a2f4f 100644 --- a/src/EGO Forum Enhancement.ts +++ b/src/EGO Forum Enhancement.ts @@ -632,11 +632,32 @@ function setupForumsConfig() { if (profileMenu) { const profileMenuObserver = new MutationObserver(() => { // Manually performing querySelector here due to odd failure to identify added node by MutationObserver - const target = profileMenu.querySelector("ul.tabPanes"); - if (target) { - handleProfileDropdown(target as HTMLElement); - profileMenuObserver.disconnect(); - } + const tabPanes = profileMenu.querySelector("ul.tabPanes"); + if (tabPanes) { + // Found tabbed menu (forum mod w/ bookmarks tab) + const insertParent = tabPanes.querySelector("li.is-active"); + const insertBefore = insertParent?.querySelector( + ":scope > a.menu-linkRow", + ); + if (insertBefore) + insertConfigButton( + insertParent as HTMLElement, + insertBefore as HTMLElement, + ); + } else if (profileMenu.querySelector("a.menu-linkRow")) { + // Didn't find, but has menu buttons now (normal direct menu) + const insertParent = profileMenu; + const insertBefore = insertParent.querySelector( + ":scope > a.menu-linkRow", + ); + if (insertBefore) + insertConfigButton( + insertParent as HTMLElement, + insertBefore as HTMLElement, + ); + } else return; // Still didn't find, wait for next mutation + + profileMenuObserver.disconnect(); }); profileMenuObserver.observe(profileMenu, { childList: true, @@ -1976,12 +1997,14 @@ function handleOnHold(target: HTMLElement) { /** * Adds a button to open the script config in the user dropdown menu - * @param {HTMLElementEventMap} event + * @param insertParent The parent element to insert into + * @param insertBefore The element to insert before * @returns void */ -function handleProfileDropdown(target: HTMLElement) { - if (target.nodeName != "UL" || !target.classList.contains("tabPanes")) - return; +function insertConfigButton( + insertParent: HTMLElement, + insertBefore: HTMLElement, +) { const btn = document.createElement("a"); btn.classList.add("menu-linkRow"); btn.innerHTML = "Forum Enhancement Script Config"; @@ -1989,12 +2012,7 @@ function handleProfileDropdown(target: HTMLElement) { btn.onclick = function () { GM_config.open(); }; - target - .querySelector("li.is-active") - ?.insertBefore( - btn, - target.querySelector("li.is-active > a.menu-linkRow"), - ); + insertParent.insertBefore(btn, insertBefore); } /**