Skip to content

Commit 8fe29fc

Browse files
authored
[FORUMS] Remove features integrated into the base forums (#121)
* update: remove MAUL profile buttons from members page & tooltip This feature has been implemented in the base forums * update: disable MAUL reauth until future fix * update: remove on hold templates This feature has been implemented in the base forums * Prettified Code! * fix: remove leftover on-hold config * fix: readd mistakenly removed maul-dropdown --------- Co-authored-by: blankdvth <blankdvth@users.noreply.github.com>
1 parent d8e0ce9 commit 8fe29fc

File tree

1 file changed

+21
-232
lines changed

1 file changed

+21
-232
lines changed

src/EGO Forum Enhancement.ts

Lines changed: 21 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name EdgeGamers Forum Enhancement%RELEASE_TYPE%
33
// @namespace https://github.com/blankdvth/eGOScripts/blob/master/src/EGO%20Forum%20Enhancement.ts
4-
// @version 4.11.6
4+
// @version 4.11.7
55
// @description Add various enhancements & QOL additions to the EdgeGamers Forums that are beneficial for Leadership members.
66
// @author blank_dvth, Skle, MSWS, PixeL
77
// @match https://www.edgegamers.com/*
@@ -33,12 +33,6 @@ interface NavbarURL_Map {
3333
url: string;
3434
}
3535

36-
interface OnHold_Map {
37-
name: string;
38-
reason: string;
39-
explain: string;
40-
}
41-
4236
interface CannedResponse {
4337
name: string;
4438
response: string;
@@ -48,7 +42,6 @@ const completedMap: Completed_Map[] = [];
4842
const signatureBlockList: string[] = [];
4943
const navbarURLs: NavbarURL_Map[] = [];
5044
const navbarRemovals: string[] = [];
51-
const onHoldTemplates: OnHold_Map[] = [];
5245
const autoMentionForums: string[] = [];
5346
const cannedResponses: { [category: string]: CannedResponse[] } = {};
5447
const appealForums: string[] = ["1234", "1236"];
@@ -170,18 +163,6 @@ function setupForumsConfig() {
170163
type: "checkbox",
171164
default: true,
172165
},
173-
"maul-button-text": {
174-
label: "MAUL Button Text",
175-
title: "The text to display on the MAUL buttons that are displayed on profiles",
176-
type: "text",
177-
default: "MAUL",
178-
},
179-
"append-profile": {
180-
label: "Append profile buttons",
181-
title: "When checked, a buttons added to profiles will be appended to their respective groups, else, they will be prepended. This does not apply to all buttons.",
182-
type: "checkbox",
183-
default: false,
184-
},
185166
"maul-reauth-enable": {
186167
label: "Enable MAUL Reauthenthication",
187168
title: "When checked, the script will automatically reauthenthicate with MAUL in the background if it's been a while since the last authenthication (see timeout below).",
@@ -272,22 +253,6 @@ function setupForumsConfig() {
272253
type: "textarea",
273254
default: "",
274255
},
275-
"on-hold-unchecked": {
276-
label: "On Hold Templates",
277-
section: [
278-
"On Hold Templates",
279-
"See <a href='https://github.com/blankdvth/eGOScripts/wiki/On-Hold-Templates' target='_blank'>this guide</a> on how to format your templates.",
280-
],
281-
type: "textarea",
282-
save: false,
283-
default:
284-
"No MAUL Account (Reason);MAUL account must be created and verified;\nSteam Verification;Steam account must be verified in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, click \"Edit Game IDs,\" then click the Sign in through Steam button under the Source ID section. Once you've done so, please reply to this post!\nMinecraft Verification;Minecraft ID must be verified in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, click \"Edit Game IDs,\" then under ID for Minecraft, input your Minecraft username, click Convert to Game ID, then log onto our Minecraft server. Once you've done so, please reply to this post!\"\nBattlefield Verification;Battlefield account must be verified in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, in MAUL hover over the home link in the top left, click help, then follow the instructions for Battlefield. Once you have done so, please reply to this post!\nDiscord Verification;Discord ID must be verfied in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, click \"Edit Game IDs,\" then click the sign in through Discord button under the discord ID section. Once you have done so, please reply to this post!\nInappropriate Name;Inappropriate Name;As for your name, Please click [URL='https://www.edgegamers.com/account/username']here[/URL] and fill out a name change request. After you fill it out, please wait while your name change request is finalized and the change is completed. Once it is done your application process will resume. If you want to have an understanding on our naming policy inside of eGO please click [URL='https://www.edgegamers.com/threads/378540/']here[/URL].",
285-
},
286-
"on-hold": {
287-
type: "hidden",
288-
default:
289-
"No MAUL Account (Reason);MAUL account must be created and verified;\nSteam Verification;Steam account must be verified in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, click \"Edit Game IDs,\" then click the Sign in through Steam button under the Source ID section. Once you've done so, please reply to this post!\nMinecraft Verification;Minecraft ID must be verified in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, click \"Edit Game IDs,\" then under ID for Minecraft, input your Minecraft username, click Convert to Game ID, then log onto our Minecraft server. Once you've done so, please reply to this post!\"\nBattlefield Verification;Battlefield account must be verified in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, in MAUL hover over the home link in the top left, click help, then follow the instructions for Battlefield. Once you have done so, please reply to this post!\nDiscord Verification;Discord ID must be verfied in MAUL;In order for you to fix this you'll need to click the MAUL link at the top of the page in the navbar, click \"Edit Game IDs,\" then click the sign in through Discord button under the discord ID section. Once you have done so, please reply to this post!\nInappropriate Name;Inappropriate Name;As for your name, Please click [URL='https://www.edgegamers.com/account/username']here[/URL] and fill out a name change request. After you fill it out, please wait while your name change request is finalized and the change is completed. Once it is done your application process will resume. If you want to have an understanding on our naming policy inside of eGO please click [URL='https://www.edgegamers.com/threads/378540/']here[/URL].",
290-
},
291256
"auto-mention-unchecked": {
292257
label: "Auto Mention (Subforum IDs)",
293258
section: [
@@ -469,7 +434,6 @@ function setupForumsConfig() {
469434
"navbar-urls-unchecked",
470435
GM_config.get("navbar-urls"),
471436
);
472-
GM_config.set("on-hold-unchecked", GM_config.get("on-hold"));
473437
GM_config.set(
474438
"auto-mention-unchecked",
475439
GM_config.get("auto-mention"),
@@ -528,26 +492,6 @@ function setupForumsConfig() {
528492
)
529493
GM_config.set("navbar-urls", urls);
530494
});
531-
GM_config.fields["on-hold-unchecked"].node?.addEventListener(
532-
"change",
533-
function () {
534-
const onHold = GM_config.get(
535-
"on-hold-unchecked",
536-
true,
537-
) as string;
538-
if (
539-
onHold.length == 0 ||
540-
onHold
541-
.split(/\r?\n/)
542-
.every((line) =>
543-
line.match(
544-
/^[^;\r\n]+;[^;\r\n]*;[^;\r\n]*$/,
545-
),
546-
)
547-
)
548-
GM_config.set("on-hold", onHold);
549-
},
550-
);
551495
GM_config.fields[
552496
"auto-mention-unchecked"
553497
].node?.addEventListener("change", function () {
@@ -605,10 +549,6 @@ function setupForumsConfig() {
605549
alert(
606550
"Invalid navbar URL list. Ensure each URL is valid, on it's own line, and all URLs are in the format 'text;url'.",
607551
);
608-
if (forgotten["on-hold-unchecked"] !== GM_config.get("on-hold"))
609-
alert(
610-
"Invalid on hold list. Ensure each line is in the format 'name;reason;explain' and that no field contains a semicolon.",
611-
);
612552
if (
613553
forgotten["auto-mention-unchecked"] !==
614554
GM_config.get("auto-mention")
@@ -670,21 +610,24 @@ function setupForumsConfig() {
670610
* Automatically authenthicates with MAUL in the background if it's been a while since the last authenthication
671611
*/
672612
function autoMAULAuth() {
673-
if (!GM_config.get("maul-reauth-enable")) return;
674-
const lastAuth = GM_getValue("lastMAULAuth", 0);
675-
if (Date.now() - lastAuth < (GM_config.get("maul-reauth") as number))
676-
return;
677-
const authLink = document.querySelector(
678-
'a.p-navEl-link[href^="/maul"]',
679-
) as HTMLAnchorElement;
680-
if (!authLink) return;
681-
GM_xmlhttpRequest({
682-
method: "GET",
683-
url: authLink.href,
684-
onload: function () {
685-
GM_setValue("lastMAULAuth", Date.now());
686-
},
687-
});
613+
console.warn(
614+
"MAUL reauth feature is currently disabled due to issues with the feature. Your config settings have been preserved, and the feature will return once fixed.",
615+
);
616+
// if (!GM_config.get("maul-reauth-enable")) return;
617+
// const lastAuth = GM_getValue("lastMAULAuth", 0);
618+
// if (Date.now() - lastAuth < (GM_config.get("maul-reauth") as number))
619+
// return;
620+
// const authLink = document.querySelector(
621+
// 'a.p-navEl-link[href^="/maul"]',
622+
// ) as HTMLAnchorElement;
623+
// if (!authLink) return;
624+
// GM_xmlhttpRequest({
625+
// method: "GET",
626+
// url: authLink.href,
627+
// onload: function () {
628+
// GM_setValue("lastMAULAuth", Date.now());
629+
// },
630+
// });
688631
}
689632

690633
/**
@@ -753,26 +696,6 @@ function loadNavbarRemovals() {
753696
});
754697
}
755698

756-
/**
757-
* Loads the on hold templates from config
758-
*/
759-
function loadOnHoldTemplates() {
760-
const onHoldTemplatesRaw = GM_config.get("on-hold") as string;
761-
if (onHoldTemplatesRaw.length == 0) return;
762-
onHoldTemplatesRaw.split(/\r?\n/).forEach((line) => {
763-
const parts = line.split(";");
764-
if (parts.length != 3) {
765-
alert("Invalid on hold line: " + line);
766-
return;
767-
}
768-
onHoldTemplates.push({
769-
name: parts[0],
770-
reason: parts[1],
771-
explain: parts[2],
772-
});
773-
});
774-
}
775-
776699
/**
777700
* Loads the auto mention list from config
778701
*/
@@ -810,10 +733,9 @@ function loadCannedResponses() {
810733
function addMAULProfileButton(div: HTMLDivElement, member_id: number | string) {
811734
createButton(
812735
"https://maul.edgegamers.com/index.php?page=home&id=" + member_id,
813-
GM_config.get("maul-button-text") as string,
736+
"MAUL",
814737
div,
815738
"_blank",
816-
GM_config.get("append-profile") as boolean,
817739
);
818740
}
819741

@@ -1647,52 +1569,6 @@ function generateResponseText(response: string) {
16471569
.replaceAll("{{{op username}}}", getOP()?.innerText ?? "");
16481570
}
16491571

1650-
/**
1651-
* Listens to and appends MAUL button when user hovers over a profile
1652-
* @param {HTMLElementEventMap} event
1653-
* @returns void
1654-
*/
1655-
function tooltipMAULListener(target: HTMLElement) {
1656-
// Make sure this specific event is the node we want
1657-
if (
1658-
target.nodeName != "DIV" ||
1659-
!target.classList.contains("tooltip-content-inner")
1660-
)
1661-
return;
1662-
1663-
// The buttongroup containing the "Follow" button
1664-
const buttenGroupOne = target.querySelector(
1665-
".memberTooltip > .memberTooltip-actions > :nth-child(1)",
1666-
) as HTMLDivElement;
1667-
if (!buttenGroupOne) return;
1668-
buttenGroupOne
1669-
.querySelector("a")
1670-
?.href.match(
1671-
/^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/,
1672-
);
1673-
const matches = buttenGroupOne
1674-
.querySelector("a")
1675-
?.href.match(
1676-
/^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/,
1677-
);
1678-
// Make sure matches were found, exit gracefully if not.
1679-
if (!matches) return;
1680-
1681-
const id = matches[1];
1682-
// The buttongroup containing the "Start conversation" button
1683-
const buttonGroupTwo = target.querySelector(
1684-
".memberTooltip > .memberTooltip-actions > :nth-child(2)",
1685-
) as HTMLDivElement;
1686-
// If the user is banned, buttonGroupTwo will be null. Default to buttonGroupOne.
1687-
createButton(
1688-
"https://maul.edgegamers.com/index.php?page=home&id=" + id,
1689-
GM_config.get("maul-button-text") as string,
1690-
buttonGroupTwo ?? buttenGroupOne,
1691-
"_blank",
1692-
GM_config.get("append-profile") as boolean,
1693-
);
1694-
}
1695-
16961572
/**
16971573
* Moves and auto-fills out the moving prompt for a thread.
16981574
* @param {string} hash The hash of the URL, should be the thread ID only
@@ -1939,62 +1815,6 @@ function handleBanAppealReport(report: boolean = false) {
19391815
}
19401816
}
19411817

1942-
/**
1943-
* Adds "On Hold" templates to the menu and increases the size of the explain box.
1944-
* @param {HTMLElementEventMap} event
1945-
* @returns void
1946-
*/
1947-
function handleOnHold(target: HTMLElement) {
1948-
if (
1949-
target.nodeName != "DIV" ||
1950-
!target.classList.contains("overlay-container") ||
1951-
!(
1952-
target.querySelector(".overlay > .overlay-title") as HTMLDivElement
1953-
).innerText.includes("on hold")
1954-
)
1955-
return;
1956-
1957-
// Event may fire twice - add a mark the first time it fires, and ignore the rest
1958-
const mark = document.createElement("input");
1959-
mark.type = "hidden";
1960-
target.append(mark);
1961-
if (target.childNodes.length > 2) return;
1962-
1963-
const body = target.querySelector(
1964-
".overlay > .overlay-content > form > .block-container > .block-body",
1965-
) as HTMLDivElement;
1966-
const reason = body.querySelector(
1967-
":nth-child(1) > dd > input",
1968-
) as HTMLInputElement;
1969-
var explain = body.querySelector(
1970-
":nth-child(2) > dd > input",
1971-
) as HTMLInputElement;
1972-
// Convert the explain input into a textarea
1973-
explain.outerHTML = explain.outerHTML.replace("input", "textarea");
1974-
// Variable gets dereferenced - reference it again
1975-
explain = body.querySelector(":nth-child(2) > dd > textarea")!;
1976-
explain.style.height = "200px";
1977-
explain.setAttribute("maxlength", "1024");
1978-
const div = body.querySelector(
1979-
":nth-child(4) > dd > div > .formSubmitRow-controls",
1980-
) as HTMLDivElement;
1981-
1982-
// Insert presets
1983-
for (var i = 0; i < onHoldTemplates.length; i++) {
1984-
addForumsPreset(
1985-
onHoldTemplates[i].name,
1986-
i.toString(),
1987-
div,
1988-
function (this: HTMLElement) {
1989-
const preset =
1990-
onHoldTemplates[this.dataset.presetId as unknown as number];
1991-
if (preset.reason) reason.value = preset.reason;
1992-
if (preset.explain) explain.value = preset.explain;
1993-
},
1994-
);
1995-
}
1996-
}
1997-
19981818
/**
19991819
* Adds a button to open the script config in the user dropdown menu
20001820
* @param insertParent The parent element to insert into
@@ -2431,38 +2251,13 @@ function blockSignatures() {
24312251
loadSignatureBlockList();
24322252
loadNavbarURLs();
24332253
loadNavbarRemovals();
2434-
loadOnHoldTemplates();
24352254
loadAutoMentionList();
24362255
loadCannedResponses();
24372256

24382257
// Determine what page we're on
24392258
const url = window.location.href;
24402259
const hash = window.location.hash;
24412260

2442-
const tooltipObserver = new MutationObserver((mutations) => {
2443-
mutations.every((mutation) => {
2444-
mutation.addedNodes.forEach((node) => {
2445-
tooltipMAULListener(node as HTMLElement);
2446-
});
2447-
});
2448-
});
2449-
tooltipObserver.observe(document.body, {
2450-
childList: true,
2451-
subtree: true,
2452-
});
2453-
2454-
const onHoldObserver = new MutationObserver((mutations) => {
2455-
mutations.every((mutation) => {
2456-
mutation.addedNodes.forEach((node) => {
2457-
handleOnHold(node as HTMLElement);
2458-
});
2459-
});
2460-
});
2461-
onHoldObserver.observe(document.body, {
2462-
childList: true,
2463-
subtree: true,
2464-
});
2465-
24662261
// Add Helpful Links to the Navigation Bar
24672262
const nav_list = document.querySelector(".p-nav-list") as HTMLUListElement;
24682263
addMAULNav(nav_list);
@@ -2473,13 +2268,7 @@ function blockSignatures() {
24732268
removeNavButtons(navbarRemovals, nav_list);
24742269
replaceLogoLink();
24752270

2476-
if (url.match(/^https:\/\/www\.edgegamers\.com\/members\/\d+/))
2477-
// Members Page
2478-
addMAULProfileButton(
2479-
document.querySelector(".memberHeader-buttons") as HTMLDivElement,
2480-
window.location.pathname.match(/\/members\/(\d+)/)![1],
2481-
);
2482-
else if (
2271+
if (
24832272
url.match(
24842273
/^^https:\/\/www\.edgegamers\.com\/threads\/\d+\/move(?:#\d+)?$/,
24852274
) &&

0 commit comments

Comments
 (0)