From 5b8bf9b1468945aaa17fe784a07bde68476b31d4 Mon Sep 17 00:00:00 2001 From: blankdvth Date: Mon, 22 Dec 2025 04:01:27 -0500 Subject: [PATCH 1/3] chore: prettify --- src/EGO Forum Enhancement.ts | 285 +++++++++++++++++------------------ src/EGO MAUL Enhancement.ts | 170 +++++++++++---------- 2 files changed, 225 insertions(+), 230 deletions(-) diff --git a/src/EGO Forum Enhancement.ts b/src/EGO Forum Enhancement.ts index f1c7144..baa6759 100644 --- a/src/EGO Forum Enhancement.ts +++ b/src/EGO Forum Enhancement.ts @@ -64,7 +64,7 @@ const countingURL: string = "https://www.edgegamers.com/threads/333944/"; function createForumsPresetButton( text: string, id: string, - callback: (event: MouseEvent) => void, + callback: (event: MouseEvent) => void ): HTMLSpanElement { const button = document.createElement("span"); button.classList.add("button"); @@ -86,7 +86,7 @@ function addForumsPreset( name: string, id: string, div: HTMLDivElement, - func: (event: MouseEvent) => void, + func: (event: MouseEvent) => void ) { div.appendChild(createForumsPresetButton(name, id, func)); } @@ -106,7 +106,7 @@ function createButton( div: HTMLDivElement, target: string = "_blank", append: boolean = false, - ins_el: HTMLElement | null = null, + ins_el: HTMLElement | null = null ) { const button = document.createElement("a"); button.href = href; @@ -459,24 +459,24 @@ function setupForumsConfig() { init: function () { GM_config.set( "move-to-completed-unchecked", - GM_config.get("move-to-completed"), + GM_config.get("move-to-completed") ); GM_config.set( "signature-block-unchecked", - GM_config.get("signature-block"), + GM_config.get("signature-block") ); GM_config.set( "navbar-urls-unchecked", - GM_config.get("navbar-urls"), + GM_config.get("navbar-urls") ); GM_config.set("on-hold-unchecked", GM_config.get("on-hold")); GM_config.set( "auto-mention-unchecked", - GM_config.get("auto-mention"), + GM_config.get("auto-mention") ); GM_config.set( "canned-responses-unchecked", - GM_config.get("canned-responses"), + GM_config.get("canned-responses") ); }, open: function (doc) { @@ -487,7 +487,7 @@ function setupForumsConfig() { function () { const maps = GM_config.get( "move-to-completed-unchecked", - true, + true ) as string; if ( maps.length == 0 || @@ -497,14 +497,14 @@ function setupForumsConfig() { ) GM_config.set("move-to-completed", maps); }, - false, + false ); GM_config.fields[ "signature-block-unchecked" ].node?.addEventListener("change", function () { const ids = GM_config.get( "signature-block-unchecked", - true, + true ) as string; if (ids.split(/\r?\n/).every((id) => id.match(/^\d+$/))) GM_config.set("signature-block", ids); @@ -514,7 +514,7 @@ function setupForumsConfig() { ].node?.addEventListener("change", function () { const urls = GM_config.get( "navbar-urls-unchecked", - true, + true ) as string; if ( urls.length == 0 || @@ -522,8 +522,8 @@ function setupForumsConfig() { .split(/\r?\n/) .every((url) => url.match( - /^[^;\r\n]+;https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(?:\/[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/, - ), + /^[^;\r\n]+;https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(?:\/[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/ + ) ) ) GM_config.set("navbar-urls", urls); @@ -533,7 +533,7 @@ function setupForumsConfig() { function () { const onHold = GM_config.get( "on-hold-unchecked", - true, + true ) as string; if ( onHold.length == 0 || @@ -541,19 +541,19 @@ function setupForumsConfig() { .split(/\r?\n/) .every((line) => line.match( - /^[^;\r\n]+;[^;\r\n]*;[^;\r\n]*$/, - ), + /^[^;\r\n]+;[^;\r\n]*;[^;\r\n]*$/ + ) ) ) GM_config.set("on-hold", onHold); - }, + } ); GM_config.fields[ "auto-mention-unchecked" ].node?.addEventListener("change", function () { const autoMention = GM_config.get( "auto-mention-unchecked", - true, + true ) as string; if ( autoMention.length == 0 || @@ -568,13 +568,13 @@ function setupForumsConfig() { ].node?.addEventListener("change", function () { const cannedResponses = GM_config.get( "canned-responses-unchecked", - true, + true ) as string; // Check if entire config matches the regex by matching all and rejoining the matches, then comparing to the original if ( [ ...cannedResponses.matchAll( - /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm, + /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm ), ] .map((i) => i[0]) @@ -589,39 +589,39 @@ function setupForumsConfig() { GM_config.get("move-to-completed") ) alert( - 'Invalid move to completed map, verify that all lines are in the format "origin id:completed id".', + 'Invalid move to completed map, verify that all lines are in the format "origin id:completed id".' ); if ( forgotten["signature-block-unchecked"] !== GM_config.get("signature-block") ) alert( - "Invalid signature block ID list. Ensure each ID is on it's own line and all IDs are numerical.", + "Invalid signature block ID list. Ensure each ID is on it's own line and all IDs are numerical." ); if ( forgotten["navbar-urls-unchecked"] !== GM_config.get("navbar-urls") ) alert( - "Invalid navbar URL list. Ensure each URL is valid, on it's own line, and all URLs are in the format 'text;url'.", + "Invalid navbar URL list. Ensure each URL is valid, on it's own line, and all URLs are in the format 'text;url'." ); if (forgotten["on-hold-unchecked"] !== GM_config.get("on-hold")) alert( - "Invalid on hold list. Ensure each line is in the format 'name;reason;explain' and that no field contains a semicolon.", + "Invalid on hold list. Ensure each line is in the format 'name;reason;explain' and that no field contains a semicolon." ); if ( forgotten["auto-mention-unchecked"] !== GM_config.get("auto-mention") ) alert( - "Invalid auto mention list. Ensure each ID is on it's own line and all IDs are numerical.", + "Invalid auto mention list. Ensure each ID is on it's own line and all IDs are numerical." ); if ( forgotten["canned-responses-unchecked"] !== GM_config.get("canned-responses") ) alert( - "Invalid canned responses list. Ensure each response is in the proper format (see the wiki for more information).", + "Invalid canned responses list. Ensure each response is in the proper format (see the wiki for more information)." ); }, }, @@ -633,7 +633,7 @@ function setupForumsConfig() { profileMenu.addEventListener( "DOMNodeInserted", handleProfileDropdown, - false, + false ); } @@ -646,7 +646,7 @@ function autoMAULAuth() { if (Date.now() - lastAuth < (GM_config.get("maul-reauth") as number)) return; const authLink = document.querySelector( - 'a.p-navEl-link[href^="/maul"]', + 'a.p-navEl-link[href^="/maul"]' ) as HTMLAnchorElement; if (!authLink) return; GM_xmlhttpRequest({ @@ -674,7 +674,7 @@ function loadCompletedMap() { } else if (!parts[0].match(/\d+/)) { // Separate to provide update notice alert( - `Invalid ID: ${parts[0]}.\nThe completed map format has been changed to use IDs instead of regexes. Please update your config.`, + `Invalid ID: ${parts[0]}.\nThe completed map format has been changed to use IDs instead of regexes. Please update your config.` ); } completedMap.push({ @@ -761,7 +761,7 @@ function loadCannedResponses() { const cannedResponsesRaw = GM_config.get("canned-responses") as string; [ ...cannedResponsesRaw.matchAll( - /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm, + /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm ), ].forEach((match) => { const category = match.groups!.category; @@ -784,7 +784,7 @@ function addMAULProfileButton(div: HTMLDivElement, member_id: number | string) { GM_config.get("maul-button-text") as string, div, "_blank", - GM_config.get("append-profile") as boolean, + GM_config.get("append-profile") as boolean ); } @@ -795,7 +795,7 @@ function addMAULProfileButton(div: HTMLDivElement, member_id: number | string) { */ function addAddBanButton(div: HTMLDivElement, data: AddBan_Data) { const urlData = LZString.compressToEncodedURIComponent( - JSON.stringify(data), + JSON.stringify(data) ); createButton( `https://maul.edgegamers.com/index.php?page=editban#${urlData}`, @@ -804,8 +804,8 @@ function addAddBanButton(div: HTMLDivElement, data: AddBan_Data) { "_blank", false, document.querySelector( - "a.button--link.button[href*='move']", - ) as HTMLAnchorElement | null, + "a.button--link.button[href*='move']" + ) as HTMLAnchorElement | null ); } @@ -824,8 +824,8 @@ function addBansButton(div: HTMLDivElement, steam_id_64: string) { "_blank", false, document.querySelector( - "a.button--link.button[href*='move']", - ) as HTMLAnchorElement | null, + "a.button--link.button[href*='move']" + ) as HTMLAnchorElement | null ); } @@ -836,7 +836,7 @@ function addBansButton(div: HTMLDivElement, steam_id_64: string) { */ function addLookupButton(div: HTMLDivElement, post_title: string) { const steam_id_unknown = post_title.match( - /^.* - .* - (?[\w\d\/\[\]\-\.:]*)$/, + /^.* - .* - (?[\w\d\/\[\]\-\.:]*)$/ ); if (steam_id_unknown) createButton( @@ -846,8 +846,8 @@ function addLookupButton(div: HTMLDivElement, post_title: string) { "_blank", false, document.querySelector( - "a.button--link.button[href*='move']", - ) as HTMLAnchorElement | null, + "a.button--link.button[href*='move']" + ) as HTMLAnchorElement | null ); } @@ -862,7 +862,7 @@ function addMoveButton( div: HTMLDivElement, url: string, text = "Move to Completed", - id = "to_completed", + id = "to_completed" ) { const post_id = url.match(/threads\/(?\d+)/); if (post_id) @@ -873,7 +873,7 @@ function addMoveButton( id, text, div, - "_self", + "_self" ); } @@ -906,12 +906,12 @@ function addPostActionBarButtons() { if (!threadId || threadId.length == 0) return; const posts = document.querySelectorAll( - ".message.message--post", + ".message.message--post" ) as NodeListOf; if (posts.length == 0) return; const isThreadUnapproved = document.querySelector( - ".blockStatus-message--moderated", + ".blockStatus-message--moderated" ); for (let i = 0; i < posts.length; i++) { @@ -919,7 +919,7 @@ function addPostActionBarButtons() { if (!post) continue; const actionBarSet = post.querySelector( - ".actionBar-set.actionBar-set--internal", + ".actionBar-set.actionBar-set--internal" ); if (!actionBarSet) continue; @@ -942,7 +942,7 @@ function addPostActionBarButtons() { // Check the post counter to see if it is the original post so we can make sure we change the button action correctly. if (i == 0) { const attributionListElements = post.querySelectorAll( - ".message-attribution-opposite.message-attribution-opposite--list li", + ".message-attribution-opposite.message-attribution-opposite--list li" ); for (let j = 0; j < attributionListElements.length; j++) { const element = attributionListElements[j] as HTMLElement; @@ -959,7 +959,7 @@ function addPostActionBarButtons() { const approvalButton = document.createElement("a"); approvalButton.classList.add( "actionBar-action", - "actionBar-action--menuItem", + "actionBar-action--menuItem" ); approvalButton.setAttribute("tabindex", "0"); @@ -986,7 +986,7 @@ async function setPostApprovalStatus( threadId: string, postId: string, approve: boolean, - reload: boolean = true, + reload: boolean = true ) { const xfToken = getXFToken(); if (!xfToken) { @@ -1010,7 +1010,7 @@ async function setPostApprovalStatus( `https://www.edgegamers.com/inline-mod/?${searchParams.toString()}`, { credentials: "same-origin", - }, + } ); if (!response.ok) { @@ -1055,7 +1055,7 @@ async function editPost( postId: string, message: string, silent: boolean = false, - clearEdits: boolean = false, + clearEdits: boolean = false ) { const xfToken = getXFToken(); if (!xfToken) { @@ -1079,7 +1079,7 @@ async function editPost( method: "POST", credentials: "same-origin", body: formdata, - }, + } ); if (!response.ok) { console.error("Failed to edit post"); @@ -1130,7 +1130,7 @@ function addNavButtons(urls: NavbarURL_Map[], nav: HTMLElement) { function removeNavButtons(removals: string[], nav: HTMLElement) { ( nav.querySelectorAll( - "li > div > a:first-of-type", + "li > div > a:first-of-type" ) as NodeListOf ).forEach((a) => { if (removals.includes(a.innerText.toLowerCase())) @@ -1145,7 +1145,7 @@ function replaceLogoLink() { if ((GM_config.get("logo-link") as string).length == 0) return; ( document.querySelectorAll( - "div.p-header-logo > a, div.p-nav-smallLogo > a", + "div.p-header-logo > a, div.p-nav-smallLogo > a" ) as NodeListOf ).forEach((a: HTMLAnchorElement) => { a.href = GM_config.get("logo-link") as string; @@ -1197,12 +1197,12 @@ function addMAULNav(nav_list: HTMLUListElement) { addNav( "https://maul.edgegamers.com/index.php?page=bans", "Bans", - nav_list, + nav_list ); addNav( "https://maul.edgegamers.com/index.php?page=users", "Users", - nav_list, + nav_list ); } } @@ -1216,13 +1216,13 @@ function getPostBox() { ) { // BBCode Editor const editors = document.querySelectorAll( - 'textarea.input[name="message"]', + 'textarea.input[name="message"]' ) as NodeListOf; return editors[editors.length - 1]?.value; } else { // Rich Editor const editors = document.querySelectorAll( - "div.fr-element.fr-view", + "div.fr-element.fr-view" ) as NodeListOf; return editors[editors.length - 1]?.innerText; } @@ -1238,13 +1238,13 @@ function getPostBoxEl() { ) { // BBCode Editor const editors = document.querySelectorAll( - 'textarea.input[name="message"]', + 'textarea.input[name="message"]' ) as NodeListOf; return editors[editors.length - 1]; } else { // Rich Editor const editors = document.querySelectorAll( - "div.fr-element.fr-view", + "div.fr-element.fr-view" ) as NodeListOf; return editors[editors.length - 1]; } @@ -1256,7 +1256,7 @@ function getPostBoxEl() { function getSteamID_F(unparsed_id: string): Promise { return new Promise((resolve, reject) => { const steam_id_match = unparsed_id.match( - /(\d{17})|(STEAM_\d:\d:\d+)|(\[U:\d:\d+\])/, + /(\d{17})|(STEAM_\d:\d:\d+)|(\[U:\d:\d+\])/ ); if (steam_id_match) try { @@ -1264,19 +1264,19 @@ function getSteamID_F(unparsed_id: string): Promise { return resolve( SteamIDConverter.isSteamID64(steam_id) ? steam_id - : SteamIDConverter.toSteamID64(steam_id), + : SteamIDConverter.toSteamID64(steam_id) ); } catch (TypeError) {} if (!GM_config.get("lookup-unknown-ids")) return reject("Could not find Steam ID"); const profile_id = unparsed_id.match( - /^(.*id\/)?(?[^\/\n\s]*)\/?$/, + /^(.*id\/)?(?[^\/\n\s]*)\/?$/ )?.groups?.game_id; if (!profile_id) return reject("Could not find Steam ID"); GM_xmlhttpRequest({ method: "GET", url: `https://api.findsteamid.com/steam/api/summary/${encodeURIComponent( - profile_id as string, + profile_id as string )}`, anonymous: true, timeout: 2500, @@ -1311,7 +1311,7 @@ function editPostBox(text: string, append: boolean = false) { ) { // BBCode Editor const editors = document.querySelectorAll( - 'div.message textarea.input[name="message"]', + 'div.message textarea.input[name="message"]' ); const editor = editors[editors.length - 1] as HTMLTextAreaElement; editor.value = append ? editor.value + text : text; @@ -1351,7 +1351,7 @@ function getThreadId() { function getUsername() { return ( document.querySelector( - "a.p-navgroup-link--user > span.p-navgroup-linkText", + "a.p-navgroup-link--user > span.p-navgroup-linkText" ) as HTMLSpanElement | null )?.innerText; } @@ -1388,7 +1388,7 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { } const html = new DOMParser().parseFromString( res.responseText, - "text/html", + "text/html" ); const latestBan = html.querySelector("table.table > tbody > tr") as | HTMLTableRowElement @@ -1431,17 +1431,17 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { 6 - Actions (don't touch) */ const cols = latestBan.querySelectorAll( - "td", + "td" ) as NodeListOf; // Indexes change, there is always Division and Admins Online, but additional rows may be added if overflowed in the table const expand = html.getElementById( - "expand_" + latestBan.dataset.num, + "expand_" + latestBan.dataset.num )!; const expandColsHeader = expand.querySelectorAll( - "span.pull-left:not(.col-xs-9)", + "span.pull-left:not(.col-xs-9)" ) as NodeListOf; const expandColsData = expand.querySelectorAll( - "span.pull-left.col-xs-9", + "span.pull-left.col-xs-9" ) as NodeListOf; const expandCols: { [key: string]: string } = {}; for (var i = 0; i < expandColsHeader.length; i++) { @@ -1461,14 +1461,12 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { .replaceAll("(", "") .replaceAll(")", "") .split(" ") - .slice(-1)[0], + .slice(-1)[0] ), - "minutes", + "minutes" ) .format( - GM_config.get( - "ban-display-expiration-format", - ) as string, + GM_config.get("ban-display-expiration-format") as string ); } @@ -1476,7 +1474,7 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { !( GM_config.get("ban-display-show-expired") || (expandCols["Duration"] ?? cols[4].innerText).includes( - "(", + "(" ) || (expandCols["Duration"] ?? cols[4].innerText) == "Permanent" ) @@ -1512,7 +1510,7 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { expandCols["Banning Admin"] ?? cols[3].innerHTML ).replace( 'href="', - 'target="_blank" href="https://maul.edgegamers.com/', + 'target="_blank" href="https://maul.edgegamers.com/' ); // Hyperlink it if (GM_config.get("ban-display-show-admins-online")) banData["Admins Online"] = expandCols["Admins Online"]; @@ -1533,14 +1531,14 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { const keyCell = document.createElement("td"); row.appendChild(keyCell).classList.add( "dataList-cell", - "small-cell", + "small-cell" ); keyCell.innerText = key; keyCell.style.textAlign = "left"; const valueCell = document.createElement("td"); row.appendChild(valueCell).classList.add( "dataList-cell", - "small-cell", + "small-cell" ); if (allowedHTMLData.includes(key)) valueCell.innerHTML = value; else valueCell.innerText = value; @@ -1548,11 +1546,11 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { } const notes = html.getElementById( - "notes_" + latestBan.dataset.num, + "notes_" + latestBan.dataset.num )!.innerHTML; if ( [...notes.matchAll(/<(.+?)>/g)].some( - (match) => match[1] != "br", + (match) => match[1] != "br" ) ) { // Failsafe checking, MAUL should always replace these with < and >, if they don't, something is wrong. @@ -1572,14 +1570,14 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { .replaceAll(/&/g, "&") .replaceAll( /https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/=]*)/g, - '$&', + '$&' ); } if (GM_config.get("ban-display-steamid")) // TODO: Allow user to customize this (like MAUL) replacedNotes = replacedNotes.replaceAll( /(^|\s|[!"#$%&'()*+,\-.:;<=>?@[\]^`{|}~])(\d{17})($|\s|[!"#$%&'()*+,\-.:;<=>?@[\]^`{|}~])/g, - '$1$2$3', + '$1$2$3' ); notesDiv.innerHTML = replacedNotes; notesDiv.style.textAlign = "left"; @@ -1635,18 +1633,18 @@ function tooltipMAULListener(event: Event) { // The buttongroup containing the "Follow" button const buttenGroupOne = target.querySelector( - ".memberTooltip > .memberTooltip-actions > :nth-child(1)", + ".memberTooltip > .memberTooltip-actions > :nth-child(1)" ) as HTMLDivElement; if (!buttenGroupOne) return; buttenGroupOne .querySelector("a") ?.href.match( - /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/, + /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/ ); const matches = buttenGroupOne .querySelector("a") ?.href.match( - /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/, + /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/ ); // Make sure matches were found, exit gracefully if not. if (!matches) return; @@ -1654,7 +1652,7 @@ function tooltipMAULListener(event: Event) { const id = matches[1]; // The buttongroup containing the "Start conversation" button const buttonGroupTwo = target.querySelector( - ".memberTooltip > .memberTooltip-actions > :nth-child(2)", + ".memberTooltip > .memberTooltip-actions > :nth-child(2)" ) as HTMLDivElement; // If the user is banned, buttonGroupTwo will be null. Default to buttonGroupOne. createButton( @@ -1662,7 +1660,7 @@ function tooltipMAULListener(event: Event) { GM_config.get("maul-button-text") as string, buttonGroupTwo ?? buttenGroupOne, "_blank", - GM_config.get("append-profile") as boolean, + GM_config.get("append-profile") as boolean ); } @@ -1679,7 +1677,7 @@ function handleThreadMovePage(hash: string) { const checkArr = Array.from(form.querySelectorAll(".inputChoices-choice")); const optArr = Array.from(drop.options); drop.selectedIndex = optArr.indexOf( - optArr.find((el) => el.value == completedId!) as HTMLOptionElement, + optArr.find((el) => el.value == completedId!) as HTMLOptionElement ); if (drop.selectedIndex == -1) { throw "Could not find forum ID"; @@ -1691,17 +1689,16 @@ function handleThreadMovePage(hash: string) { .find( (el) => el.textContent === - "Notify members watching the destination forum", + "Notify members watching the destination forum" ) ?.querySelector("label > input") as HTMLInputElement ).checked = false; ( checkArr - .find( - (el) => - el.textContent?.startsWith( - "Notify thread starter of this action.", - ), + .find((el) => + el.textContent?.startsWith( + "Notify thread starter of this action." + ) ) ?.querySelector("label > input") as HTMLInputElement ).checked = false; @@ -1725,7 +1722,7 @@ function isLeadership(str: string) { */ function handleForumsList() { const private_category = document.querySelector( - ".block--category1240 > .block-container > .block-body", + ".block--category1240 > .block-container > .block-body" ); const subforum = document.createElement("div"); @@ -1736,7 +1733,7 @@ function handleForumsList() { response.text().then(function (text) { forumHtml.innerHTML = text; const thread = forumHtml.querySelector( - ".js-threadList > :first-child", + ".js-threadList > :first-child" ); // If the last thread in the bin is unread, mark the forum as unread @@ -1744,16 +1741,16 @@ function handleForumsList() { subforum.classList.add("node--unread"); } const userHref = thread?.querySelector( - ".structItem-cell--main > .structItem-minor > .structItem-parts > li > a", + ".structItem-cell--main > .structItem-minor > .structItem-parts > li > a" )?.outerHTML; const threadTitle = thread?.querySelector( - ".structItem-cell--main > .structItem-title", + ".structItem-cell--main > .structItem-title" )?.innerHTML; // Queryselector gets the parent and var references all children in case of prefixes const date = thread?.querySelector( - ".structItem-cell--latest > a > time", + ".structItem-cell--latest > a > time" )?.outerHTML; const icon = thread?.querySelector( - ".structItem-cell--icon > .structItem-iconContainer > a", + ".structItem-cell--icon > .structItem-iconContainer > a" )?.outerHTML; subforum.innerHTML = @@ -1791,7 +1788,7 @@ function handleGenericThread() { button_group as HTMLDivElement, window.location.href, "Move to Completed", - completedMap[i].completedId, + completedMap[i].completedId ); break; } @@ -1801,8 +1798,8 @@ function handleGenericThread() { // Trash Bin addTrashButton( button_group?.querySelector( - "div.menu > div.menu-content > a[href$=move]", - ) as HTMLDivElement, + "div.menu > div.menu-content > a[href$=move]" + ) as HTMLDivElement ); } if (isLeadership(breadcrumbs)) @@ -1844,19 +1841,19 @@ function handleBanAppealReport(report: boolean = false) { const post_title = (document.querySelector(".p-title") as HTMLDivElement) .innerText; const button_group = document.querySelector( - "div.buttonGroup", + "div.buttonGroup" ) as HTMLDivElement; addMAULProfileButton( button_group, ( document.querySelector( - ".message-name > a.username", + ".message-name > a.username" ) as HTMLAnchorElement - ).href.substring(35), + ).href.substring(35) ); const title_match = post_title.match( - /^(?.*) - (?.*) - (.*?\/?(?[\w\d\/\[\]\-\.: ]*).*)$/, + /^(?.*) - (?.*) - (.*?\/?(?[\w\d\/\[\]\-\.: ]*).*)$/ ); if (title_match) { getSteamID_F(title_match.groups!.game_id) @@ -1879,7 +1876,7 @@ function handleBanAppealReport(report: boolean = false) { button.remove(); displayBanInfo( steam_id_64 as string, - document.querySelector(".p-body-main")!, + document.querySelector(".p-body-main")! ); }; @@ -1891,12 +1888,12 @@ function handleBanAppealReport(report: boolean = false) { button.appendChild(button_text); button_group.insertBefore( button, - button_group.lastElementChild, + button_group.lastElementChild ); } else displayBanInfo( steam_id_64, - document.querySelector(".p-body-main")!, + document.querySelector(".p-body-main")! ); } addBansButton(button_group, steam_id_64); @@ -1937,13 +1934,13 @@ function handleOnHold(event: Event) { if (target.childNodes.length > 2) return; const body = target.querySelector( - ".overlay > .overlay-content > form > .block-container > .block-body", + ".overlay > .overlay-content > form > .block-container > .block-body" ) as HTMLDivElement; const reason = body.querySelector( - ":nth-child(1) > dd > input", + ":nth-child(1) > dd > input" ) as HTMLInputElement; var explain = body.querySelector( - ":nth-child(2) > dd > input", + ":nth-child(2) > dd > input" ) as HTMLInputElement; // Convert the explain input into a textarea explain.outerHTML = explain.outerHTML.replace("input", "textarea"); @@ -1952,7 +1949,7 @@ function handleOnHold(event: Event) { explain.style.height = "200px"; explain.setAttribute("maxlength", "1024"); const div = body.querySelector( - ":nth-child(4) > dd > div > .formSubmitRow-controls", + ":nth-child(4) > dd > div > .formSubmitRow-controls" ) as HTMLDivElement; // Insert presets @@ -1966,7 +1963,7 @@ function handleOnHold(event: Event) { onHoldTemplates[this.dataset.presetId as unknown as number]; if (preset.reason) reason.value = preset.reason; if (preset.explain) explain.value = preset.explain; - }, + } ); } } @@ -1992,7 +1989,7 @@ function handleProfileDropdown(event: Event) { .querySelector("li.is-active") ?.insertBefore( btn, - target.querySelector("li.is-active > a.menu-linkRow"), + target.querySelector("li.is-active > a.menu-linkRow") ); } @@ -2019,8 +2016,8 @@ function autoMention(focus: boolean) { if (username && userId && getPostBox()?.trim().length == 0) { editPostBox( `[USER=${userId}]@${username}[/USER]${"\n".repeat( - GM_config.get("auto-mention-newlines") as number, - )}`, + GM_config.get("auto-mention-newlines") as number + )}` ); if (focus) getPostBoxEl().focus(); } @@ -2033,11 +2030,11 @@ function autoCount() { if (getPostBox()?.trim().length != 0) return; // For some reason using a[class=""] doesn't work, so we have to use a:not(a[class]) const posts = document.querySelectorAll( - "header.message-attribution > ul.message-attribution-opposite > li > a:not(a[class])", + "header.message-attribution > ul.message-attribution-opposite > li > a:not(a[class])" ) as NodeListOf; if (posts.length == 0) return; const lastNum = Number( - posts[posts.length - 1].innerText.substring(1).replaceAll(",", ""), + posts[posts.length - 1].innerText.substring(1).replaceAll(",", "") ); // Remove the # and commas from the post number editPostBox(`${lastNum + 1}`); } @@ -2097,7 +2094,7 @@ function handleAutoCount() { */ function handleCannedResponses() { const bar = document.querySelector( - "div.formButtonGroup-extra", + "div.formButtonGroup-extra" ) as HTMLDivElement; if (!bar) { console.warn("Could not find post box button bar"); @@ -2127,7 +2124,7 @@ function handleCannedResponses() { "menu", "menu--structural", "menu--potentialFixed", - "menu--left", + "menu--left" ); dropdownMenu.style.zIndex = "800"; dropdownMenu.style.display = "none"; @@ -2210,23 +2207,23 @@ function handleUnapprovePost(postBox: HTMLDivElement) { ) { if (GM_config.get("rich-override")) console.warn( - "Post box is in rich editor mode, but rich editor override is enabled. The rich editor is NOT supported.", + "Post box is in rich editor mode, but rich editor override is enabled. The rich editor is NOT supported." ); else return; } const threadId = getThreadId(); const threadBody = document.querySelector( - "div.block-body.js-replyNewMessageContainer", + "div.block-body.js-replyNewMessageContainer" ) as HTMLDivElement; const postButton = document.querySelector( - "button.button--icon--reply:not(#post-unapprove-button)", + "button.button--icon--reply:not(#post-unapprove-button)" ) as HTMLButtonElement; const postUnapproveButton = document.createElement("a"); // Using a so that it doesn't submit the form postUnapproveButton.classList.add( "button--primary", "button", "button--icon", - "button--icon--reply", + "button--icon--reply" ); postUnapproveButton.style.marginRight = "4px"; postUnapproveButton.id = "post-unapprove-button"; @@ -2247,20 +2244,20 @@ function handleUnapprovePost(postBox: HTMLDivElement) { if (node.nodeName === "ARTICLE") { const postId = node.dataset.content?.replaceAll( "post-", - "", + "" ); if (threadId && postId) setPostApprovalStatus( threadId, postId, false, - false, + false ).then(() => { editPost( threadId, postId, postBoxContent, - true, + true ).then(() => { window.location.reload(); }); @@ -2289,7 +2286,7 @@ function handleUnapprovePost(postBox: HTMLDivElement) { function handleApplicationPage() { const children = ( document.querySelector( - ".dataList-row > .dataList-cell > a", + ".dataList-row > .dataList-cell > a" ) as HTMLAnchorElement ).parentElement?.children; if (!children) return; @@ -2311,7 +2308,7 @@ function blockSignatures() { )?.dataset.userId; if (userId != null && signatureBlockList.includes(userId)) { const signature = post.querySelector( - "aside.message-signature > div", + "aside.message-signature > div" ) as HTMLDivElement; // iframe's are added after page load, using a DOMNodeInserted event to work around that function signatureEvent(event: Event) { @@ -2326,19 +2323,19 @@ function blockSignatures() { signature.addEventListener( "DOMNodeInserted", signatureEvent, - false, + false ); // Set the SRC of content to nothing (data:,), empty string is not used as it may cause additional requests to the page // Issue originated back in 2009, unsure if it is still a problem but best to lean on the safe side. // Was fixed in FireFox a while ago, not sure about Chrome ( signature.querySelectorAll( - "img[src]", + "img[src]" ) as NodeListOf ).forEach((img) => (img.src = "data:,")); ( signature.querySelectorAll( - "video[poster]", + "video[poster]" ) as NodeListOf ).forEach((video) => { video.dataset.poster = video.poster; @@ -2346,7 +2343,7 @@ function blockSignatures() { }); ( signature.querySelectorAll( - "source[src]", + "source[src]" ) as NodeListOf ).forEach((source) => { source.dataset.src = source.src; @@ -2359,14 +2356,14 @@ function blockSignatures() { signature.style.display = ""; ( signature.querySelectorAll( - "img[src][data-url]", + "img[src][data-url]" ) as NodeListOf ).forEach((img) => { img.src = img.dataset.url as string; }); ( signature.querySelectorAll( - "iframe[src][data-src]", + "iframe[src][data-src]" ) as NodeListOf ).forEach((iframe) => { iframe.src = iframe.dataset.src as string; @@ -2374,7 +2371,7 @@ function blockSignatures() { }); ( signature.querySelectorAll( - "video[poster][data-poster]", + "video[poster][data-poster]" ) as NodeListOf ).forEach((video) => { video.poster = video.dataset.poster as string; @@ -2382,7 +2379,7 @@ function blockSignatures() { }); ( signature.querySelectorAll( - "source[src][data-src]", + "source[src][data-src]" ) as NodeListOf ).forEach((source) => { source.src = source.dataset.src as string; @@ -2391,7 +2388,7 @@ function blockSignatures() { signature.removeEventListener( "DOMNodeInserted", signatureEvent, - false, + false ); btn.remove(); }; @@ -2423,7 +2420,7 @@ function blockSignatures() { document.body.addEventListener( "DOMNodeInserted", tooltipMAULListener, - false, + false ); document.body.addEventListener("DOMNodeInserted", handleOnHold, false); @@ -2441,11 +2438,11 @@ function blockSignatures() { // Members Page addMAULProfileButton( document.querySelector(".memberHeader-buttons") as HTMLDivElement, - window.location.pathname.match(/\/members\/(\d+)/)![1], + window.location.pathname.match(/\/members\/(\d+)/)![1] ); else if ( url.match( - /^^https:\/\/www\.edgegamers\.com\/threads\/\d+\/move(?:#\d+)?$/, + /^^https:\/\/www\.edgegamers\.com\/threads\/\d+\/move(?:#\d+)?$/ ) && hash != "" ) diff --git a/src/EGO MAUL Enhancement.ts b/src/EGO MAUL Enhancement.ts index a74cc68..a89db6c 100644 --- a/src/EGO MAUL Enhancement.ts +++ b/src/EGO MAUL Enhancement.ts @@ -60,10 +60,10 @@ let USERNAME = ""; // Current username let STEAMID_REGEX: RegExp; // SteamID regex (unsafeWindow as any as Unsafe_Window).generateFlagHash = function ( - text: string, + text: string ) { generateHash(text + GM_config.get("flag-salt")).then((hash) => - console.log(hash), + console.log(hash) ); }; @@ -78,7 +78,7 @@ function addMAULPreset( name: string, id: string, div: HTMLDivElement, - func: (event: MouseEvent) => void, + func: (event: MouseEvent) => void ) { div.appendChild(createMAULPresetButton(name, id, func)); } @@ -113,7 +113,7 @@ function createPresetDiv(): HTMLDivElement { function createMAULPresetButton( text: string, id: string, - callback: (event: MouseEvent) => void, + callback: (event: MouseEvent) => void ): HTMLButtonElement { const button = document.createElement("button"); button.classList.add("btn", "btn-default"); @@ -133,7 +133,7 @@ function createMAULPresetButton( function createLinkButton( text: string, link: string, - target = "_blank", + target = "_blank" ): HTMLAnchorElement { const a = document.createElement("a"); a.classList.add("btn", "btn-default"); @@ -179,7 +179,7 @@ function generateForumsURL(threadId: any, postId: any): string { */ function getSteamID_M( unparsed_id: string, - reject_existing: boolean = false, + reject_existing: boolean = false ): Promise { return new Promise((resolve, reject) => { if (SteamIDConverter.isSteamID64(unparsed_id)) @@ -193,13 +193,13 @@ function getSteamID_M( if (!GM_config.get("lookup-unknown-ids")) return reject("Could not find Steam ID"); const profile_id = unparsed_id.match( - /^(.*id\/)?(?[^\/\n\s]*)\/?$/, + /^(.*id\/)?(?[^\/\n\s]*)\/?$/ )?.groups?.game_id; if (!profile_id) return reject("Could not find Steam ID"); GM_xmlhttpRequest({ method: "GET", url: `https://api.findsteamid.com/steam/api/summary/${encodeURIComponent( - profile_id as string, + profile_id as string )}`, anonymous: true, timeout: 2500, @@ -362,22 +362,22 @@ function setupMAULConfig() { init: function () { GM_config.set( "presets-add-unchecked", - GM_config.get("presets-add"), + GM_config.get("presets-add") ); GM_config.set( "presets-edit-unchecked", - GM_config.get("presets-edit"), + GM_config.get("presets-edit") ); GM_config.set( "flag-fields-unchecked", - GM_config.get("flag-fields"), + GM_config.get("flag-fields") ); if ((GM_config.get("flag-salt") as string).length == 0) { GM_config.set( "flag-salt", [...Array(45)] .map(() => (~~(Math.random() * 36)).toString(36)) - .join(""), + .join("") ); GM_config.save(); } @@ -390,7 +390,7 @@ function setupMAULConfig() { function () { const presets = GM_config.get( "presets-add-unchecked", - true, + true ) as string; if ( @@ -398,13 +398,13 @@ function setupMAULConfig() { .split(/\r?\n/) .every((line) => line.match( - /^[^;\r\n]+;[^;\r\n]*;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/, - ), + /^[^;\r\n]+;[^;\r\n]*;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/ + ) ) ) GM_config.set("presets-add", presets); }, - false, + false ); GM_config.fields[ "presets-edit-unchecked" @@ -413,7 +413,7 @@ function setupMAULConfig() { function () { const presets = GM_config.get( "presets-edit-unchecked", - true, + true ) as string; if ( @@ -421,13 +421,13 @@ function setupMAULConfig() { .split(/\r?\n/) .every((line) => line.match( - /^[^;\r\n]+;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/, - ), + /^[^;\r\n]+;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/ + ) ) ) GM_config.set("presets-edit", presets); }, - false, + false ); GM_config.fields[ "flag-fields-unchecked" @@ -436,19 +436,19 @@ function setupMAULConfig() { function () { const flagFields = GM_config.get( "flag-fields-unchecked", - true, + true ) as string; if ( flagFields .split(/\r?\n/) .every((line) => - line.match(/^[^;\r\n]+;[^;\r\n]+$/), + line.match(/^[^;\r\n]+;[^;\r\n]+$/) ) ) GM_config.set("flag-fields", flagFields); }, - false, + false ); }, save: function (forgotten) { @@ -458,21 +458,21 @@ function setupMAULConfig() { GM_config.get("presets-add") ) alert( - 'Invalid preset format for "Add Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.', + 'Invalid preset format for "Add Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.' ); if ( forgotten["presets-edit-unchecked"] !== GM_config.get("presets-edit") ) alert( - 'Invalid preset format for "Edit Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.', + 'Invalid preset format for "Edit Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.' ); if ( forgotten["flag-fields-unchecked"] !== GM_config.get("flag-fields") ) alert( - 'Invalid flag format for "Flag Fields", value not saved.\nVerify that each line has 2 semicolon-separated values.', + 'Invalid flag format for "Flag Fields", value not saved.\nVerify that each line has 2 semicolon-separated values.' ); } }, @@ -480,7 +480,7 @@ function setupMAULConfig() { css: "textarea {width: 100%; height: 160px; resize: vertical;} #maul-config_field_flag-salt {filter: blur(6px)} #maul-config_field_flag-salt:focus {filter: blur(0)}", }); const dropdownMenu = document.querySelector( - ".user-dropdown > ul.dropdown-menu", + ".user-dropdown > ul.dropdown-menu" ); if (dropdownMenu) { const configButton = document.createElement("li"); @@ -491,7 +491,7 @@ function setupMAULConfig() { configButton.style.cursor = "pointer"; dropdownMenu.insertBefore( configButton, - dropdownMenu.querySelector("li.divider"), + dropdownMenu.querySelector("li.divider") ); } } @@ -515,7 +515,7 @@ function loadAdmins() { function loadUsername() { if (USERNAME) return; const dropdown = document.querySelector( - "a.dropdown-toggle", + "a.dropdown-toggle" ) as HTMLAnchorElement; if (dropdown) USERNAME = dropdown.innerText.trim(); } @@ -616,7 +616,7 @@ function handleAddBan(hash: string = "") { if (preset.length == 0) ( document.getElementById( - "length", + "length" ) as HTMLInputElement ).disabled = true; } @@ -630,10 +630,10 @@ function handleAddBan(hash: string = "") { ).value = preset.notes; ( document.getElementById( - "preventAmnesty", + "preventAmnesty" ) as HTMLInputElement ).checked = preset.pa; - }, + } ); } @@ -643,7 +643,7 @@ function handleAddBan(hash: string = "") { !(document.getElementById("gameId") as HTMLInputElement).disabled ) { const data: AddBan_Data = JSON.parse( - LZString.decompressFromEncodedURIComponent(hash), + LZString.decompressFromEncodedURIComponent(hash) ); if (data.name) (document.getElementById("handle") as HTMLInputElement).value = @@ -681,7 +681,7 @@ function handleEditBan() { if (preset.length == 0) ( document.getElementById( - "length", + "length" ) as HTMLInputElement ).disabled = true; } @@ -698,16 +698,17 @@ function handleEditBan() { (preset.addUsername ? " " + USERNAME : ""); ( document.getElementById( - "preventAmnesty", + "preventAmnesty" ) as HTMLInputElement ).checked = preset.pa; - }, + } ); } // Steam ID buttons - const idGroup = document.querySelector(".control-label[for=gameId]") - ?.parentElement; + const idGroup = document.querySelector( + ".control-label[for=gameId]" + )?.parentElement; const id = idGroup?.querySelector("p")?.innerText; if (id) { const idDiv = document.createElement("div"); @@ -718,30 +719,27 @@ function handleEditBan() { idDiv.appendChild( createLinkButton( "Steam", - "https://steamcommunity.com/profiles/" + id, - ), + "https://steamcommunity.com/profiles/" + id + ) ); idDiv.appendChild( createLinkButton( "GameME", "https://edgegamers.gameme.com/search?si=uniqueid&rc=all&q=" + - SteamIDConverter.toSteamID(id), - ), + SteamIDConverter.toSteamID(id) + ) ); idDiv.appendChild( - createLinkButton("SteamID (IO)", "https://steamid.io/lookup/" + id), + createLinkButton("SteamID (IO)", "https://steamid.io/lookup/" + id) ); idDiv.appendChild( - createLinkButton( - "SteamID (UK)", - "https://steamid.uk/profile/" + id, - ), + createLinkButton("SteamID (UK)", "https://steamid.uk/profile/" + id) ); } // IP buttons const ipGroup = Array.from( - document.querySelectorAll(".control-label"), + document.querySelectorAll(".control-label") ).find((el) => el.textContent === "IP")?.parentElement; // BECAUSE MAUL HAS THE IP LABELED WITH THE WRONG FOR const ip = ipGroup?.querySelector("p")?.innerText; if (ip) { @@ -756,15 +754,15 @@ function handleEditBan() { GM_config.get("spur-account") ? `https://spur.us/app/context?q=${ip}` : `https://spur.us/context/${ip}`, - "_blank", - ), + "_blank" + ) ); ip_div.appendChild( createLinkButton( "Check IPInfo", "https://ipinfo.io/" + ip, - "_blank", - ), + "_blank" + ) ); } @@ -776,9 +774,9 @@ function handleEditBan() { "div > p.form-control-static, div > input:not(input#preventAmnesty)" + (GM_config.get("flag-ignore-notes") ? "" - : ", div > textarea"), - ), - ), + : ", div > textarea") + ) + ) ).then((arr) => { const insEl = div.parentElement!; const presetHeader = insEl.querySelector("h4"); @@ -786,7 +784,7 @@ function handleEditBan() { const alert = document.createElement("div"); alert.classList.add( "alert", - "alert-" + GM_config.get("flag-alert"), + "alert-" + GM_config.get("flag-alert") ); alert.innerText = result.message; insEl.insertBefore(alert, presetHeader); @@ -817,34 +815,34 @@ function handleProfile() { /(?:https?:\/\/)?(?:www\.)?edge-gamers\.com\/forums\/showthread\.php\?p=(\d+)(?:#?post(\d+))?/g, function (match, threadId, postId) { return generateForumsURL(threadId, postId); - }, + } ) .replaceAll( /(?:https?:\/\/)?(?:www\.)?edge-gamers\.com\/forums\/showthread\.php\?(\d+)[\-a-zA-Z]*/g, function (match, threadId) { return generateForumsURL(threadId, null); - }, + } ) .replaceAll( /https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/=]*)/g, - '$&', + '$&' ) .replaceAll( /([^\/\d]|^)(\d{17})([^\/\d]|$)/g, - '$1$2$3', + '$1$2$3' ); }); // Attempt to get Source ID const sourceIdHref = document.querySelector( - 'span.floatRight > a[href^="https://steamcommunity.com/profiles/"]', + 'span.floatRight > a[href^="https://steamcommunity.com/profiles/"]' ) as HTMLAnchorElement; const id = sourceIdHref.innerText; const btn = createLinkButton( "GameME", "https://edgegamers.gameme.com/search?si=uniqueid&rc=all&q=" + SteamIDConverter.toSteamID(id), - "_blank", + "_blank" ); btn.classList.remove("btn", "btn-default"); sourceIdHref.parentElement?.insertBefore(btn, sourceIdHref); @@ -861,7 +859,7 @@ function handleBanList() { if (GM_config.get("convert-search")) document .querySelector( - "div.form-group.input-group > span.input-group-btn > button", + "div.form-group.input-group > span.input-group-btn > button" ) ?.addEventListener( "click", @@ -869,12 +867,12 @@ function handleBanList() { if ( ( document.getElementById( - "banQType", + "banQType" ) as HTMLSelectElement ).value == "gameId" ) { const searchBox = document.querySelector( - "div.form-group.input-group > input[name='q']", + "div.form-group.input-group > input[name='q']" ) as HTMLInputElement | undefined; const id = searchBox?.value; if (id) { @@ -890,23 +888,23 @@ function handleBanList() { } } }, - false, + false ); if (GM_config.get("flag-enabled")) findFlagFields( Array.from( document.querySelectorAll( - "tbody > tr > td:not(.text-center)", - ) as NodeListOf, + "tbody > tr > td:not(.text-center)" + ) as NodeListOf ).filter( (el) => el.innerText.trim() != "" && - el.parentElement?.style.display != "none", - ), + el.parentElement?.style.display != "none" + ) ).then((arr) => { arr.forEach((result) => { result.element.style.backgroundColor = GM_config.get( - "flag-colour", + "flag-colour" ) as string; result.element.title = result.message; }); @@ -924,7 +922,7 @@ function assignAdminsOnlineHyperlink(str: string) { if (id == undefined) continue; str = str.replace( admin, - `${admin}`, + `${admin}` ); } return str; @@ -936,7 +934,7 @@ function assignAdminsOnlineHyperlink(str: string) { function convertBanningAdmins() { if (Object.keys(knownAdmins).length === 0) loadAdmins(); const headers = document.querySelectorAll( - ".expand > td > span.pull-left", + ".expand > td > span.pull-left" ) as NodeListOf; let wasAdminOnline = false; for (const header of headers) { @@ -956,8 +954,8 @@ function convertBanningAdmins() { function convertGameIDs() { const banIDs = Array.from( document.querySelectorAll( - "table.table-bordered td:not([class]):nth-child(3)", - ), + "table.table-bordered td:not([class]):nth-child(3)" + ) ).filter((el) => !el.querySelector("a")) as HTMLTableCellElement[]; banIDs.forEach((el) => { const id = @@ -973,7 +971,7 @@ function convertGameIDs() { */ function convertDurationFields() { const banDurations = document.querySelectorAll( - "table.table-bordered td:nth-child(5)", + "table.table-bordered td:nth-child(5)" ) as NodeListOf; const convertMinutesToHuman = (minutes: number) => { @@ -1024,7 +1022,7 @@ function convertDurationFields() { const convertedExpiration = moment( (el.parentElement!.firstElementChild as HTMLTableCellElement) - .innerText, + .innerText ) .add(banDuration, "minutes") .format(GM_config.get("datetimeformat-expiration") as string); @@ -1047,7 +1045,7 @@ function convertDurationFields() { * @returns {Array} Elements that match the flagFields */ async function findFlagFields( - elements: Array, + elements: Array ): Promise> { const results: Array = []; for (const el of elements) { @@ -1075,11 +1073,11 @@ function updateBanNoteURLs() { const replaced = unescapedInnerHTML .replaceAll( /https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/=]*)/g, - '$&', + '$&' ) .replaceAll( STEAMID_REGEX, // The most finnicky regex in history, too many false-positives and false-negatives. User configurable for that reason. - '$1$2$3', + '$1$2$3' ); // If the text hasn't been changed, move on if (replaced === unescapedInnerHTML) return; @@ -1097,13 +1095,13 @@ function updateBanNoteURLs() { .original as string; event.target?.removeEventListener( "mousedown", - handleEditNotesClick as EventListener, + handleEditNotesClick as EventListener ); delete (banNote as HTMLSpanElement).dataset.original; } editNotes?.addEventListener( "mousedown", - handleEditNotesClick as EventListener, + handleEditNotesClick as EventListener ); }); } @@ -1122,28 +1120,28 @@ function updateBanNoteURLs() { if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban\/?(?:#.+)?$/, + /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban\/?(?:#.+)?$/ ) ) // Add Ban Page (not Edit, that will have &id=12345 in the URL) handleAddBan(hash.substring(1)); else if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban&id=\d+\/?$/, + /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban&id=\d+\/?$/ ) ) // Edit Ban Page handleEditBan(); else if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=home&id=\d+\/?$/, + /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=home&id=\d+\/?$/ ) ) // Profile Page handleProfile(); else if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?.*page=bans.*$/, + /^https:\/\/maul\.edgegamers\.com\/index\.php\?.*page=bans.*$/ ) ) // List Ban Page From 4055ad47f5dcfd4abe232c8e6ddc5c7c13d401f1 Mon Sep 17 00:00:00 2001 From: blankdvth Date: Mon, 22 Dec 2025 04:02:18 -0500 Subject: [PATCH 2/3] fix: migrate from DOMNodeInserted to MutationObserver --- src/EGO Forum Enhancement.ts | 98 +++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/src/EGO Forum Enhancement.ts b/src/EGO Forum Enhancement.ts index baa6759..8407d9b 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.4 +// @version 4.11.5 // @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/* @@ -629,12 +629,19 @@ function setupForumsConfig() { }); const profileMenu = document.querySelector("div.js-visitorMenuBody"); - if (profileMenu) - profileMenu.addEventListener( - "DOMNodeInserted", - handleProfileDropdown, - false - ); + if (profileMenu) { + const profileMenuObserver = new MutationObserver((mutations) => { + mutations.every((mutation) => { + mutation.addedNodes.forEach((node) => { + handleProfileDropdown(node as HTMLElement); + }); + }); + }); + profileMenuObserver.observe(profileMenu, { + childList: true, + subtree: true, + }); + } } /** @@ -1621,10 +1628,8 @@ function generateResponseText(response: string) { * @param {HTMLElementEventMap} event * @returns void */ -function tooltipMAULListener(event: Event) { +function tooltipMAULListener(target: HTMLElement) { // Make sure this specific event is the node we want - if (!event.target) return; - const target = event.target as HTMLElement; if ( target.nodeName != "DIV" || !target.classList.contains("tooltip-content-inner") @@ -1915,9 +1920,7 @@ function handleBanAppealReport(report: boolean = false) { * @param {HTMLElementEventMap} event * @returns void */ -function handleOnHold(event: Event) { - if (!event.target) return; - const target = event.target as HTMLElement; +function handleOnHold(target: HTMLElement) { if ( target.nodeName != "DIV" || !target.classList.contains("overlay-container") || @@ -1973,9 +1976,7 @@ function handleOnHold(event: Event) { * @param {HTMLElementEventMap} event * @returns void */ -function handleProfileDropdown(event: Event) { - if (!event.target) return; - const target = event.target as HTMLElement; +function handleProfileDropdown(target: HTMLElement) { if (target.nodeName != "UL" || !target.classList.contains("tabPanes")) return; const btn = document.createElement("a"); @@ -2310,21 +2311,25 @@ function blockSignatures() { const signature = post.querySelector( "aside.message-signature > div" ) as HTMLDivElement; - // iframe's are added after page load, using a DOMNodeInserted event to work around that - function signatureEvent(event: Event) { - if (!event.target) return; - if (!((event.target as HTMLElement).nodeName === "IFRAME")) - return; - (event.target as HTMLIFrameElement).dataset.src = ( - event.target as HTMLIFrameElement + // iframe's are added after page load, using a MutationObserver to work around that + function signatureEvent(target: HTMLElement) { + if (!(target.nodeName === "IFRAME")) return; + (target as HTMLIFrameElement).dataset.src = ( + target as HTMLIFrameElement ).src; - (event.target as HTMLIFrameElement).src = "about:blank"; + (target as HTMLIFrameElement).src = "about:blank"; } - signature.addEventListener( - "DOMNodeInserted", - signatureEvent, - false - ); + const signatureObserver = new MutationObserver((mutations) => { + mutations.every((mutation) => { + mutation.addedNodes.forEach((node) => { + signatureEvent(node as HTMLElement); + }); + }); + }); + signatureObserver.observe(signature, { + childList: true, + subtree: true, + }); // Set the SRC of content to nothing (data:,), empty string is not used as it may cause additional requests to the page // Issue originated back in 2009, unsure if it is still a problem but best to lean on the safe side. // Was fixed in FireFox a while ago, not sure about Chrome @@ -2385,11 +2390,7 @@ function blockSignatures() { source.src = source.dataset.src as string; delete source.dataset.src; }); - signature.removeEventListener( - "DOMNodeInserted", - signatureEvent, - false - ); + signatureObserver.disconnect(); btn.remove(); }; btn.innerHTML = "Load Signature"; @@ -2417,12 +2418,29 @@ function blockSignatures() { const url = window.location.href; const hash = window.location.hash; - document.body.addEventListener( - "DOMNodeInserted", - tooltipMAULListener, - false - ); - document.body.addEventListener("DOMNodeInserted", handleOnHold, false); + const tooltipObserver = new MutationObserver((mutations) => { + mutations.every((mutation) => { + mutation.addedNodes.forEach((node) => { + tooltipMAULListener(node as HTMLElement); + }); + }); + }); + tooltipObserver.observe(document.body, { + childList: true, + subtree: true, + }); + + const onHoldObserver = new MutationObserver((mutations) => { + mutations.every((mutation) => { + mutation.addedNodes.forEach((node) => { + handleOnHold(node as HTMLElement); + }); + }); + }); + onHoldObserver.observe(document.body, { + childList: true, + subtree: true, + }); // Add Helpful Links to the Navigation Bar const nav_list = document.querySelector(".p-nav-list") as HTMLUListElement; From d8d44150b52bb3ae1a926285ed3f71a10843e2c5 Mon Sep 17 00:00:00 2001 From: blankdvth Date: Mon, 22 Dec 2025 09:04:20 +0000 Subject: [PATCH 3/3] Prettified Code! --- src/EGO Forum Enhancement.ts | 272 ++++++++++++++++++----------------- src/EGO MAUL Enhancement.ts | 175 +++++++++++----------- 2 files changed, 226 insertions(+), 221 deletions(-) diff --git a/src/EGO Forum Enhancement.ts b/src/EGO Forum Enhancement.ts index 8407d9b..f79c05d 100644 --- a/src/EGO Forum Enhancement.ts +++ b/src/EGO Forum Enhancement.ts @@ -64,7 +64,7 @@ const countingURL: string = "https://www.edgegamers.com/threads/333944/"; function createForumsPresetButton( text: string, id: string, - callback: (event: MouseEvent) => void + callback: (event: MouseEvent) => void, ): HTMLSpanElement { const button = document.createElement("span"); button.classList.add("button"); @@ -86,7 +86,7 @@ function addForumsPreset( name: string, id: string, div: HTMLDivElement, - func: (event: MouseEvent) => void + func: (event: MouseEvent) => void, ) { div.appendChild(createForumsPresetButton(name, id, func)); } @@ -106,7 +106,7 @@ function createButton( div: HTMLDivElement, target: string = "_blank", append: boolean = false, - ins_el: HTMLElement | null = null + ins_el: HTMLElement | null = null, ) { const button = document.createElement("a"); button.href = href; @@ -459,24 +459,24 @@ function setupForumsConfig() { init: function () { GM_config.set( "move-to-completed-unchecked", - GM_config.get("move-to-completed") + GM_config.get("move-to-completed"), ); GM_config.set( "signature-block-unchecked", - GM_config.get("signature-block") + GM_config.get("signature-block"), ); GM_config.set( "navbar-urls-unchecked", - GM_config.get("navbar-urls") + GM_config.get("navbar-urls"), ); GM_config.set("on-hold-unchecked", GM_config.get("on-hold")); GM_config.set( "auto-mention-unchecked", - GM_config.get("auto-mention") + GM_config.get("auto-mention"), ); GM_config.set( "canned-responses-unchecked", - GM_config.get("canned-responses") + GM_config.get("canned-responses"), ); }, open: function (doc) { @@ -487,7 +487,7 @@ function setupForumsConfig() { function () { const maps = GM_config.get( "move-to-completed-unchecked", - true + true, ) as string; if ( maps.length == 0 || @@ -497,14 +497,14 @@ function setupForumsConfig() { ) GM_config.set("move-to-completed", maps); }, - false + false, ); GM_config.fields[ "signature-block-unchecked" ].node?.addEventListener("change", function () { const ids = GM_config.get( "signature-block-unchecked", - true + true, ) as string; if (ids.split(/\r?\n/).every((id) => id.match(/^\d+$/))) GM_config.set("signature-block", ids); @@ -514,7 +514,7 @@ function setupForumsConfig() { ].node?.addEventListener("change", function () { const urls = GM_config.get( "navbar-urls-unchecked", - true + true, ) as string; if ( urls.length == 0 || @@ -522,8 +522,8 @@ function setupForumsConfig() { .split(/\r?\n/) .every((url) => url.match( - /^[^;\r\n]+;https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(?:\/[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/ - ) + /^[^;\r\n]+;https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(?:\/[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/, + ), ) ) GM_config.set("navbar-urls", urls); @@ -533,7 +533,7 @@ function setupForumsConfig() { function () { const onHold = GM_config.get( "on-hold-unchecked", - true + true, ) as string; if ( onHold.length == 0 || @@ -541,19 +541,19 @@ function setupForumsConfig() { .split(/\r?\n/) .every((line) => line.match( - /^[^;\r\n]+;[^;\r\n]*;[^;\r\n]*$/ - ) + /^[^;\r\n]+;[^;\r\n]*;[^;\r\n]*$/, + ), ) ) GM_config.set("on-hold", onHold); - } + }, ); GM_config.fields[ "auto-mention-unchecked" ].node?.addEventListener("change", function () { const autoMention = GM_config.get( "auto-mention-unchecked", - true + true, ) as string; if ( autoMention.length == 0 || @@ -568,13 +568,13 @@ function setupForumsConfig() { ].node?.addEventListener("change", function () { const cannedResponses = GM_config.get( "canned-responses-unchecked", - true + true, ) as string; // Check if entire config matches the regex by matching all and rejoining the matches, then comparing to the original if ( [ ...cannedResponses.matchAll( - /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm + /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm, ), ] .map((i) => i[0]) @@ -589,39 +589,39 @@ function setupForumsConfig() { GM_config.get("move-to-completed") ) alert( - 'Invalid move to completed map, verify that all lines are in the format "origin id:completed id".' + 'Invalid move to completed map, verify that all lines are in the format "origin id:completed id".', ); if ( forgotten["signature-block-unchecked"] !== GM_config.get("signature-block") ) alert( - "Invalid signature block ID list. Ensure each ID is on it's own line and all IDs are numerical." + "Invalid signature block ID list. Ensure each ID is on it's own line and all IDs are numerical.", ); if ( forgotten["navbar-urls-unchecked"] !== GM_config.get("navbar-urls") ) alert( - "Invalid navbar URL list. Ensure each URL is valid, on it's own line, and all URLs are in the format 'text;url'." + "Invalid navbar URL list. Ensure each URL is valid, on it's own line, and all URLs are in the format 'text;url'.", ); if (forgotten["on-hold-unchecked"] !== GM_config.get("on-hold")) alert( - "Invalid on hold list. Ensure each line is in the format 'name;reason;explain' and that no field contains a semicolon." + "Invalid on hold list. Ensure each line is in the format 'name;reason;explain' and that no field contains a semicolon.", ); if ( forgotten["auto-mention-unchecked"] !== GM_config.get("auto-mention") ) alert( - "Invalid auto mention list. Ensure each ID is on it's own line and all IDs are numerical." + "Invalid auto mention list. Ensure each ID is on it's own line and all IDs are numerical.", ); if ( forgotten["canned-responses-unchecked"] !== GM_config.get("canned-responses") ) alert( - "Invalid canned responses list. Ensure each response is in the proper format (see the wiki for more information)." + "Invalid canned responses list. Ensure each response is in the proper format (see the wiki for more information).", ); }, }, @@ -653,7 +653,7 @@ function autoMAULAuth() { if (Date.now() - lastAuth < (GM_config.get("maul-reauth") as number)) return; const authLink = document.querySelector( - 'a.p-navEl-link[href^="/maul"]' + 'a.p-navEl-link[href^="/maul"]', ) as HTMLAnchorElement; if (!authLink) return; GM_xmlhttpRequest({ @@ -681,7 +681,7 @@ function loadCompletedMap() { } else if (!parts[0].match(/\d+/)) { // Separate to provide update notice alert( - `Invalid ID: ${parts[0]}.\nThe completed map format has been changed to use IDs instead of regexes. Please update your config.` + `Invalid ID: ${parts[0]}.\nThe completed map format has been changed to use IDs instead of regexes. Please update your config.`, ); } completedMap.push({ @@ -768,7 +768,7 @@ function loadCannedResponses() { const cannedResponsesRaw = GM_config.get("canned-responses") as string; [ ...cannedResponsesRaw.matchAll( - /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm + /(?:===\n|^)- (?.+)\n- (?.+)\n(?(?:.|\n)+?)\n===/gm, ), ].forEach((match) => { const category = match.groups!.category; @@ -791,7 +791,7 @@ function addMAULProfileButton(div: HTMLDivElement, member_id: number | string) { GM_config.get("maul-button-text") as string, div, "_blank", - GM_config.get("append-profile") as boolean + GM_config.get("append-profile") as boolean, ); } @@ -802,7 +802,7 @@ function addMAULProfileButton(div: HTMLDivElement, member_id: number | string) { */ function addAddBanButton(div: HTMLDivElement, data: AddBan_Data) { const urlData = LZString.compressToEncodedURIComponent( - JSON.stringify(data) + JSON.stringify(data), ); createButton( `https://maul.edgegamers.com/index.php?page=editban#${urlData}`, @@ -811,8 +811,8 @@ function addAddBanButton(div: HTMLDivElement, data: AddBan_Data) { "_blank", false, document.querySelector( - "a.button--link.button[href*='move']" - ) as HTMLAnchorElement | null + "a.button--link.button[href*='move']", + ) as HTMLAnchorElement | null, ); } @@ -831,8 +831,8 @@ function addBansButton(div: HTMLDivElement, steam_id_64: string) { "_blank", false, document.querySelector( - "a.button--link.button[href*='move']" - ) as HTMLAnchorElement | null + "a.button--link.button[href*='move']", + ) as HTMLAnchorElement | null, ); } @@ -843,7 +843,7 @@ function addBansButton(div: HTMLDivElement, steam_id_64: string) { */ function addLookupButton(div: HTMLDivElement, post_title: string) { const steam_id_unknown = post_title.match( - /^.* - .* - (?[\w\d\/\[\]\-\.:]*)$/ + /^.* - .* - (?[\w\d\/\[\]\-\.:]*)$/, ); if (steam_id_unknown) createButton( @@ -853,8 +853,8 @@ function addLookupButton(div: HTMLDivElement, post_title: string) { "_blank", false, document.querySelector( - "a.button--link.button[href*='move']" - ) as HTMLAnchorElement | null + "a.button--link.button[href*='move']", + ) as HTMLAnchorElement | null, ); } @@ -869,7 +869,7 @@ function addMoveButton( div: HTMLDivElement, url: string, text = "Move to Completed", - id = "to_completed" + id = "to_completed", ) { const post_id = url.match(/threads\/(?\d+)/); if (post_id) @@ -880,7 +880,7 @@ function addMoveButton( id, text, div, - "_self" + "_self", ); } @@ -913,12 +913,12 @@ function addPostActionBarButtons() { if (!threadId || threadId.length == 0) return; const posts = document.querySelectorAll( - ".message.message--post" + ".message.message--post", ) as NodeListOf; if (posts.length == 0) return; const isThreadUnapproved = document.querySelector( - ".blockStatus-message--moderated" + ".blockStatus-message--moderated", ); for (let i = 0; i < posts.length; i++) { @@ -926,7 +926,7 @@ function addPostActionBarButtons() { if (!post) continue; const actionBarSet = post.querySelector( - ".actionBar-set.actionBar-set--internal" + ".actionBar-set.actionBar-set--internal", ); if (!actionBarSet) continue; @@ -949,7 +949,7 @@ function addPostActionBarButtons() { // Check the post counter to see if it is the original post so we can make sure we change the button action correctly. if (i == 0) { const attributionListElements = post.querySelectorAll( - ".message-attribution-opposite.message-attribution-opposite--list li" + ".message-attribution-opposite.message-attribution-opposite--list li", ); for (let j = 0; j < attributionListElements.length; j++) { const element = attributionListElements[j] as HTMLElement; @@ -966,7 +966,7 @@ function addPostActionBarButtons() { const approvalButton = document.createElement("a"); approvalButton.classList.add( "actionBar-action", - "actionBar-action--menuItem" + "actionBar-action--menuItem", ); approvalButton.setAttribute("tabindex", "0"); @@ -993,7 +993,7 @@ async function setPostApprovalStatus( threadId: string, postId: string, approve: boolean, - reload: boolean = true + reload: boolean = true, ) { const xfToken = getXFToken(); if (!xfToken) { @@ -1017,7 +1017,7 @@ async function setPostApprovalStatus( `https://www.edgegamers.com/inline-mod/?${searchParams.toString()}`, { credentials: "same-origin", - } + }, ); if (!response.ok) { @@ -1062,7 +1062,7 @@ async function editPost( postId: string, message: string, silent: boolean = false, - clearEdits: boolean = false + clearEdits: boolean = false, ) { const xfToken = getXFToken(); if (!xfToken) { @@ -1086,7 +1086,7 @@ async function editPost( method: "POST", credentials: "same-origin", body: formdata, - } + }, ); if (!response.ok) { console.error("Failed to edit post"); @@ -1137,7 +1137,7 @@ function addNavButtons(urls: NavbarURL_Map[], nav: HTMLElement) { function removeNavButtons(removals: string[], nav: HTMLElement) { ( nav.querySelectorAll( - "li > div > a:first-of-type" + "li > div > a:first-of-type", ) as NodeListOf ).forEach((a) => { if (removals.includes(a.innerText.toLowerCase())) @@ -1152,7 +1152,7 @@ function replaceLogoLink() { if ((GM_config.get("logo-link") as string).length == 0) return; ( document.querySelectorAll( - "div.p-header-logo > a, div.p-nav-smallLogo > a" + "div.p-header-logo > a, div.p-nav-smallLogo > a", ) as NodeListOf ).forEach((a: HTMLAnchorElement) => { a.href = GM_config.get("logo-link") as string; @@ -1204,12 +1204,12 @@ function addMAULNav(nav_list: HTMLUListElement) { addNav( "https://maul.edgegamers.com/index.php?page=bans", "Bans", - nav_list + nav_list, ); addNav( "https://maul.edgegamers.com/index.php?page=users", "Users", - nav_list + nav_list, ); } } @@ -1223,13 +1223,13 @@ function getPostBox() { ) { // BBCode Editor const editors = document.querySelectorAll( - 'textarea.input[name="message"]' + 'textarea.input[name="message"]', ) as NodeListOf; return editors[editors.length - 1]?.value; } else { // Rich Editor const editors = document.querySelectorAll( - "div.fr-element.fr-view" + "div.fr-element.fr-view", ) as NodeListOf; return editors[editors.length - 1]?.innerText; } @@ -1245,13 +1245,13 @@ function getPostBoxEl() { ) { // BBCode Editor const editors = document.querySelectorAll( - 'textarea.input[name="message"]' + 'textarea.input[name="message"]', ) as NodeListOf; return editors[editors.length - 1]; } else { // Rich Editor const editors = document.querySelectorAll( - "div.fr-element.fr-view" + "div.fr-element.fr-view", ) as NodeListOf; return editors[editors.length - 1]; } @@ -1263,7 +1263,7 @@ function getPostBoxEl() { function getSteamID_F(unparsed_id: string): Promise { return new Promise((resolve, reject) => { const steam_id_match = unparsed_id.match( - /(\d{17})|(STEAM_\d:\d:\d+)|(\[U:\d:\d+\])/ + /(\d{17})|(STEAM_\d:\d:\d+)|(\[U:\d:\d+\])/, ); if (steam_id_match) try { @@ -1271,19 +1271,19 @@ function getSteamID_F(unparsed_id: string): Promise { return resolve( SteamIDConverter.isSteamID64(steam_id) ? steam_id - : SteamIDConverter.toSteamID64(steam_id) + : SteamIDConverter.toSteamID64(steam_id), ); } catch (TypeError) {} if (!GM_config.get("lookup-unknown-ids")) return reject("Could not find Steam ID"); const profile_id = unparsed_id.match( - /^(.*id\/)?(?[^\/\n\s]*)\/?$/ + /^(.*id\/)?(?[^\/\n\s]*)\/?$/, )?.groups?.game_id; if (!profile_id) return reject("Could not find Steam ID"); GM_xmlhttpRequest({ method: "GET", url: `https://api.findsteamid.com/steam/api/summary/${encodeURIComponent( - profile_id as string + profile_id as string, )}`, anonymous: true, timeout: 2500, @@ -1318,7 +1318,7 @@ function editPostBox(text: string, append: boolean = false) { ) { // BBCode Editor const editors = document.querySelectorAll( - 'div.message textarea.input[name="message"]' + 'div.message textarea.input[name="message"]', ); const editor = editors[editors.length - 1] as HTMLTextAreaElement; editor.value = append ? editor.value + text : text; @@ -1358,7 +1358,7 @@ function getThreadId() { function getUsername() { return ( document.querySelector( - "a.p-navgroup-link--user > span.p-navgroup-linkText" + "a.p-navgroup-link--user > span.p-navgroup-linkText", ) as HTMLSpanElement | null )?.innerText; } @@ -1395,7 +1395,7 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { } const html = new DOMParser().parseFromString( res.responseText, - "text/html" + "text/html", ); const latestBan = html.querySelector("table.table > tbody > tr") as | HTMLTableRowElement @@ -1438,17 +1438,17 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { 6 - Actions (don't touch) */ const cols = latestBan.querySelectorAll( - "td" + "td", ) as NodeListOf; // Indexes change, there is always Division and Admins Online, but additional rows may be added if overflowed in the table const expand = html.getElementById( - "expand_" + latestBan.dataset.num + "expand_" + latestBan.dataset.num, )!; const expandColsHeader = expand.querySelectorAll( - "span.pull-left:not(.col-xs-9)" + "span.pull-left:not(.col-xs-9)", ) as NodeListOf; const expandColsData = expand.querySelectorAll( - "span.pull-left.col-xs-9" + "span.pull-left.col-xs-9", ) as NodeListOf; const expandCols: { [key: string]: string } = {}; for (var i = 0; i < expandColsHeader.length; i++) { @@ -1468,12 +1468,14 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { .replaceAll("(", "") .replaceAll(")", "") .split(" ") - .slice(-1)[0] + .slice(-1)[0], ), - "minutes" + "minutes", ) .format( - GM_config.get("ban-display-expiration-format") as string + GM_config.get( + "ban-display-expiration-format", + ) as string, ); } @@ -1481,7 +1483,7 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { !( GM_config.get("ban-display-show-expired") || (expandCols["Duration"] ?? cols[4].innerText).includes( - "(" + "(", ) || (expandCols["Duration"] ?? cols[4].innerText) == "Permanent" ) @@ -1517,7 +1519,7 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { expandCols["Banning Admin"] ?? cols[3].innerHTML ).replace( 'href="', - 'target="_blank" href="https://maul.edgegamers.com/' + 'target="_blank" href="https://maul.edgegamers.com/', ); // Hyperlink it if (GM_config.get("ban-display-show-admins-online")) banData["Admins Online"] = expandCols["Admins Online"]; @@ -1538,14 +1540,14 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { const keyCell = document.createElement("td"); row.appendChild(keyCell).classList.add( "dataList-cell", - "small-cell" + "small-cell", ); keyCell.innerText = key; keyCell.style.textAlign = "left"; const valueCell = document.createElement("td"); row.appendChild(valueCell).classList.add( "dataList-cell", - "small-cell" + "small-cell", ); if (allowedHTMLData.includes(key)) valueCell.innerHTML = value; else valueCell.innerText = value; @@ -1553,11 +1555,11 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { } const notes = html.getElementById( - "notes_" + latestBan.dataset.num + "notes_" + latestBan.dataset.num, )!.innerHTML; if ( [...notes.matchAll(/<(.+?)>/g)].some( - (match) => match[1] != "br" + (match) => match[1] != "br", ) ) { // Failsafe checking, MAUL should always replace these with < and >, if they don't, something is wrong. @@ -1577,14 +1579,14 @@ function displayBanInfo(steam_id_64: string, insertBefore: HTMLElement) { .replaceAll(/&/g, "&") .replaceAll( /https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/=]*)/g, - '$&' + '$&', ); } if (GM_config.get("ban-display-steamid")) // TODO: Allow user to customize this (like MAUL) replacedNotes = replacedNotes.replaceAll( /(^|\s|[!"#$%&'()*+,\-.:;<=>?@[\]^`{|}~])(\d{17})($|\s|[!"#$%&'()*+,\-.:;<=>?@[\]^`{|}~])/g, - '$1$2$3' + '$1$2$3', ); notesDiv.innerHTML = replacedNotes; notesDiv.style.textAlign = "left"; @@ -1638,18 +1640,18 @@ function tooltipMAULListener(target: HTMLElement) { // The buttongroup containing the "Follow" button const buttenGroupOne = target.querySelector( - ".memberTooltip > .memberTooltip-actions > :nth-child(1)" + ".memberTooltip > .memberTooltip-actions > :nth-child(1)", ) as HTMLDivElement; if (!buttenGroupOne) return; buttenGroupOne .querySelector("a") ?.href.match( - /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/ + /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/, ); const matches = buttenGroupOne .querySelector("a") ?.href.match( - /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/ + /^https:\/\/www\.edgegamers\.com\/members\/(\d+)\/follow$/, ); // Make sure matches were found, exit gracefully if not. if (!matches) return; @@ -1657,7 +1659,7 @@ function tooltipMAULListener(target: HTMLElement) { const id = matches[1]; // The buttongroup containing the "Start conversation" button const buttonGroupTwo = target.querySelector( - ".memberTooltip > .memberTooltip-actions > :nth-child(2)" + ".memberTooltip > .memberTooltip-actions > :nth-child(2)", ) as HTMLDivElement; // If the user is banned, buttonGroupTwo will be null. Default to buttonGroupOne. createButton( @@ -1665,7 +1667,7 @@ function tooltipMAULListener(target: HTMLElement) { GM_config.get("maul-button-text") as string, buttonGroupTwo ?? buttenGroupOne, "_blank", - GM_config.get("append-profile") as boolean + GM_config.get("append-profile") as boolean, ); } @@ -1682,7 +1684,7 @@ function handleThreadMovePage(hash: string) { const checkArr = Array.from(form.querySelectorAll(".inputChoices-choice")); const optArr = Array.from(drop.options); drop.selectedIndex = optArr.indexOf( - optArr.find((el) => el.value == completedId!) as HTMLOptionElement + optArr.find((el) => el.value == completedId!) as HTMLOptionElement, ); if (drop.selectedIndex == -1) { throw "Could not find forum ID"; @@ -1694,7 +1696,7 @@ function handleThreadMovePage(hash: string) { .find( (el) => el.textContent === - "Notify members watching the destination forum" + "Notify members watching the destination forum", ) ?.querySelector("label > input") as HTMLInputElement ).checked = false; @@ -1702,8 +1704,8 @@ function handleThreadMovePage(hash: string) { checkArr .find((el) => el.textContent?.startsWith( - "Notify thread starter of this action." - ) + "Notify thread starter of this action.", + ), ) ?.querySelector("label > input") as HTMLInputElement ).checked = false; @@ -1727,7 +1729,7 @@ function isLeadership(str: string) { */ function handleForumsList() { const private_category = document.querySelector( - ".block--category1240 > .block-container > .block-body" + ".block--category1240 > .block-container > .block-body", ); const subforum = document.createElement("div"); @@ -1738,7 +1740,7 @@ function handleForumsList() { response.text().then(function (text) { forumHtml.innerHTML = text; const thread = forumHtml.querySelector( - ".js-threadList > :first-child" + ".js-threadList > :first-child", ); // If the last thread in the bin is unread, mark the forum as unread @@ -1746,16 +1748,16 @@ function handleForumsList() { subforum.classList.add("node--unread"); } const userHref = thread?.querySelector( - ".structItem-cell--main > .structItem-minor > .structItem-parts > li > a" + ".structItem-cell--main > .structItem-minor > .structItem-parts > li > a", )?.outerHTML; const threadTitle = thread?.querySelector( - ".structItem-cell--main > .structItem-title" + ".structItem-cell--main > .structItem-title", )?.innerHTML; // Queryselector gets the parent and var references all children in case of prefixes const date = thread?.querySelector( - ".structItem-cell--latest > a > time" + ".structItem-cell--latest > a > time", )?.outerHTML; const icon = thread?.querySelector( - ".structItem-cell--icon > .structItem-iconContainer > a" + ".structItem-cell--icon > .structItem-iconContainer > a", )?.outerHTML; subforum.innerHTML = @@ -1793,7 +1795,7 @@ function handleGenericThread() { button_group as HTMLDivElement, window.location.href, "Move to Completed", - completedMap[i].completedId + completedMap[i].completedId, ); break; } @@ -1803,8 +1805,8 @@ function handleGenericThread() { // Trash Bin addTrashButton( button_group?.querySelector( - "div.menu > div.menu-content > a[href$=move]" - ) as HTMLDivElement + "div.menu > div.menu-content > a[href$=move]", + ) as HTMLDivElement, ); } if (isLeadership(breadcrumbs)) @@ -1846,19 +1848,19 @@ function handleBanAppealReport(report: boolean = false) { const post_title = (document.querySelector(".p-title") as HTMLDivElement) .innerText; const button_group = document.querySelector( - "div.buttonGroup" + "div.buttonGroup", ) as HTMLDivElement; addMAULProfileButton( button_group, ( document.querySelector( - ".message-name > a.username" + ".message-name > a.username", ) as HTMLAnchorElement - ).href.substring(35) + ).href.substring(35), ); const title_match = post_title.match( - /^(?.*) - (?.*) - (.*?\/?(?[\w\d\/\[\]\-\.: ]*).*)$/ + /^(?.*) - (?.*) - (.*?\/?(?[\w\d\/\[\]\-\.: ]*).*)$/, ); if (title_match) { getSteamID_F(title_match.groups!.game_id) @@ -1881,7 +1883,7 @@ function handleBanAppealReport(report: boolean = false) { button.remove(); displayBanInfo( steam_id_64 as string, - document.querySelector(".p-body-main")! + document.querySelector(".p-body-main")!, ); }; @@ -1893,12 +1895,12 @@ function handleBanAppealReport(report: boolean = false) { button.appendChild(button_text); button_group.insertBefore( button, - button_group.lastElementChild + button_group.lastElementChild, ); } else displayBanInfo( steam_id_64, - document.querySelector(".p-body-main")! + document.querySelector(".p-body-main")!, ); } addBansButton(button_group, steam_id_64); @@ -1937,13 +1939,13 @@ function handleOnHold(target: HTMLElement) { if (target.childNodes.length > 2) return; const body = target.querySelector( - ".overlay > .overlay-content > form > .block-container > .block-body" + ".overlay > .overlay-content > form > .block-container > .block-body", ) as HTMLDivElement; const reason = body.querySelector( - ":nth-child(1) > dd > input" + ":nth-child(1) > dd > input", ) as HTMLInputElement; var explain = body.querySelector( - ":nth-child(2) > dd > input" + ":nth-child(2) > dd > input", ) as HTMLInputElement; // Convert the explain input into a textarea explain.outerHTML = explain.outerHTML.replace("input", "textarea"); @@ -1952,7 +1954,7 @@ function handleOnHold(target: HTMLElement) { explain.style.height = "200px"; explain.setAttribute("maxlength", "1024"); const div = body.querySelector( - ":nth-child(4) > dd > div > .formSubmitRow-controls" + ":nth-child(4) > dd > div > .formSubmitRow-controls", ) as HTMLDivElement; // Insert presets @@ -1966,7 +1968,7 @@ function handleOnHold(target: HTMLElement) { onHoldTemplates[this.dataset.presetId as unknown as number]; if (preset.reason) reason.value = preset.reason; if (preset.explain) explain.value = preset.explain; - } + }, ); } } @@ -1990,7 +1992,7 @@ function handleProfileDropdown(target: HTMLElement) { .querySelector("li.is-active") ?.insertBefore( btn, - target.querySelector("li.is-active > a.menu-linkRow") + target.querySelector("li.is-active > a.menu-linkRow"), ); } @@ -2017,8 +2019,8 @@ function autoMention(focus: boolean) { if (username && userId && getPostBox()?.trim().length == 0) { editPostBox( `[USER=${userId}]@${username}[/USER]${"\n".repeat( - GM_config.get("auto-mention-newlines") as number - )}` + GM_config.get("auto-mention-newlines") as number, + )}`, ); if (focus) getPostBoxEl().focus(); } @@ -2031,11 +2033,11 @@ function autoCount() { if (getPostBox()?.trim().length != 0) return; // For some reason using a[class=""] doesn't work, so we have to use a:not(a[class]) const posts = document.querySelectorAll( - "header.message-attribution > ul.message-attribution-opposite > li > a:not(a[class])" + "header.message-attribution > ul.message-attribution-opposite > li > a:not(a[class])", ) as NodeListOf; if (posts.length == 0) return; const lastNum = Number( - posts[posts.length - 1].innerText.substring(1).replaceAll(",", "") + posts[posts.length - 1].innerText.substring(1).replaceAll(",", ""), ); // Remove the # and commas from the post number editPostBox(`${lastNum + 1}`); } @@ -2095,7 +2097,7 @@ function handleAutoCount() { */ function handleCannedResponses() { const bar = document.querySelector( - "div.formButtonGroup-extra" + "div.formButtonGroup-extra", ) as HTMLDivElement; if (!bar) { console.warn("Could not find post box button bar"); @@ -2125,7 +2127,7 @@ function handleCannedResponses() { "menu", "menu--structural", "menu--potentialFixed", - "menu--left" + "menu--left", ); dropdownMenu.style.zIndex = "800"; dropdownMenu.style.display = "none"; @@ -2208,23 +2210,23 @@ function handleUnapprovePost(postBox: HTMLDivElement) { ) { if (GM_config.get("rich-override")) console.warn( - "Post box is in rich editor mode, but rich editor override is enabled. The rich editor is NOT supported." + "Post box is in rich editor mode, but rich editor override is enabled. The rich editor is NOT supported.", ); else return; } const threadId = getThreadId(); const threadBody = document.querySelector( - "div.block-body.js-replyNewMessageContainer" + "div.block-body.js-replyNewMessageContainer", ) as HTMLDivElement; const postButton = document.querySelector( - "button.button--icon--reply:not(#post-unapprove-button)" + "button.button--icon--reply:not(#post-unapprove-button)", ) as HTMLButtonElement; const postUnapproveButton = document.createElement("a"); // Using a so that it doesn't submit the form postUnapproveButton.classList.add( "button--primary", "button", "button--icon", - "button--icon--reply" + "button--icon--reply", ); postUnapproveButton.style.marginRight = "4px"; postUnapproveButton.id = "post-unapprove-button"; @@ -2245,20 +2247,20 @@ function handleUnapprovePost(postBox: HTMLDivElement) { if (node.nodeName === "ARTICLE") { const postId = node.dataset.content?.replaceAll( "post-", - "" + "", ); if (threadId && postId) setPostApprovalStatus( threadId, postId, false, - false + false, ).then(() => { editPost( threadId, postId, postBoxContent, - true + true, ).then(() => { window.location.reload(); }); @@ -2287,7 +2289,7 @@ function handleUnapprovePost(postBox: HTMLDivElement) { function handleApplicationPage() { const children = ( document.querySelector( - ".dataList-row > .dataList-cell > a" + ".dataList-row > .dataList-cell > a", ) as HTMLAnchorElement ).parentElement?.children; if (!children) return; @@ -2309,7 +2311,7 @@ function blockSignatures() { )?.dataset.userId; if (userId != null && signatureBlockList.includes(userId)) { const signature = post.querySelector( - "aside.message-signature > div" + "aside.message-signature > div", ) as HTMLDivElement; // iframe's are added after page load, using a MutationObserver to work around that function signatureEvent(target: HTMLElement) { @@ -2335,12 +2337,12 @@ function blockSignatures() { // Was fixed in FireFox a while ago, not sure about Chrome ( signature.querySelectorAll( - "img[src]" + "img[src]", ) as NodeListOf ).forEach((img) => (img.src = "data:,")); ( signature.querySelectorAll( - "video[poster]" + "video[poster]", ) as NodeListOf ).forEach((video) => { video.dataset.poster = video.poster; @@ -2348,7 +2350,7 @@ function blockSignatures() { }); ( signature.querySelectorAll( - "source[src]" + "source[src]", ) as NodeListOf ).forEach((source) => { source.dataset.src = source.src; @@ -2361,14 +2363,14 @@ function blockSignatures() { signature.style.display = ""; ( signature.querySelectorAll( - "img[src][data-url]" + "img[src][data-url]", ) as NodeListOf ).forEach((img) => { img.src = img.dataset.url as string; }); ( signature.querySelectorAll( - "iframe[src][data-src]" + "iframe[src][data-src]", ) as NodeListOf ).forEach((iframe) => { iframe.src = iframe.dataset.src as string; @@ -2376,7 +2378,7 @@ function blockSignatures() { }); ( signature.querySelectorAll( - "video[poster][data-poster]" + "video[poster][data-poster]", ) as NodeListOf ).forEach((video) => { video.poster = video.dataset.poster as string; @@ -2384,7 +2386,7 @@ function blockSignatures() { }); ( signature.querySelectorAll( - "source[src][data-src]" + "source[src][data-src]", ) as NodeListOf ).forEach((source) => { source.src = source.dataset.src as string; @@ -2456,11 +2458,11 @@ function blockSignatures() { // Members Page addMAULProfileButton( document.querySelector(".memberHeader-buttons") as HTMLDivElement, - window.location.pathname.match(/\/members\/(\d+)/)![1] + window.location.pathname.match(/\/members\/(\d+)/)![1], ); else if ( url.match( - /^^https:\/\/www\.edgegamers\.com\/threads\/\d+\/move(?:#\d+)?$/ + /^^https:\/\/www\.edgegamers\.com\/threads\/\d+\/move(?:#\d+)?$/, ) && hash != "" ) diff --git a/src/EGO MAUL Enhancement.ts b/src/EGO MAUL Enhancement.ts index a89db6c..2666f8e 100644 --- a/src/EGO MAUL Enhancement.ts +++ b/src/EGO MAUL Enhancement.ts @@ -60,10 +60,10 @@ let USERNAME = ""; // Current username let STEAMID_REGEX: RegExp; // SteamID regex (unsafeWindow as any as Unsafe_Window).generateFlagHash = function ( - text: string + text: string, ) { generateHash(text + GM_config.get("flag-salt")).then((hash) => - console.log(hash) + console.log(hash), ); }; @@ -78,7 +78,7 @@ function addMAULPreset( name: string, id: string, div: HTMLDivElement, - func: (event: MouseEvent) => void + func: (event: MouseEvent) => void, ) { div.appendChild(createMAULPresetButton(name, id, func)); } @@ -113,7 +113,7 @@ function createPresetDiv(): HTMLDivElement { function createMAULPresetButton( text: string, id: string, - callback: (event: MouseEvent) => void + callback: (event: MouseEvent) => void, ): HTMLButtonElement { const button = document.createElement("button"); button.classList.add("btn", "btn-default"); @@ -133,7 +133,7 @@ function createMAULPresetButton( function createLinkButton( text: string, link: string, - target = "_blank" + target = "_blank", ): HTMLAnchorElement { const a = document.createElement("a"); a.classList.add("btn", "btn-default"); @@ -179,7 +179,7 @@ function generateForumsURL(threadId: any, postId: any): string { */ function getSteamID_M( unparsed_id: string, - reject_existing: boolean = false + reject_existing: boolean = false, ): Promise { return new Promise((resolve, reject) => { if (SteamIDConverter.isSteamID64(unparsed_id)) @@ -193,13 +193,13 @@ function getSteamID_M( if (!GM_config.get("lookup-unknown-ids")) return reject("Could not find Steam ID"); const profile_id = unparsed_id.match( - /^(.*id\/)?(?[^\/\n\s]*)\/?$/ + /^(.*id\/)?(?[^\/\n\s]*)\/?$/, )?.groups?.game_id; if (!profile_id) return reject("Could not find Steam ID"); GM_xmlhttpRequest({ method: "GET", url: `https://api.findsteamid.com/steam/api/summary/${encodeURIComponent( - profile_id as string + profile_id as string, )}`, anonymous: true, timeout: 2500, @@ -362,22 +362,22 @@ function setupMAULConfig() { init: function () { GM_config.set( "presets-add-unchecked", - GM_config.get("presets-add") + GM_config.get("presets-add"), ); GM_config.set( "presets-edit-unchecked", - GM_config.get("presets-edit") + GM_config.get("presets-edit"), ); GM_config.set( "flag-fields-unchecked", - GM_config.get("flag-fields") + GM_config.get("flag-fields"), ); if ((GM_config.get("flag-salt") as string).length == 0) { GM_config.set( "flag-salt", [...Array(45)] .map(() => (~~(Math.random() * 36)).toString(36)) - .join("") + .join(""), ); GM_config.save(); } @@ -390,7 +390,7 @@ function setupMAULConfig() { function () { const presets = GM_config.get( "presets-add-unchecked", - true + true, ) as string; if ( @@ -398,13 +398,13 @@ function setupMAULConfig() { .split(/\r?\n/) .every((line) => line.match( - /^[^;\r\n]+;[^;\r\n]*;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/ - ) + /^[^;\r\n]+;[^;\r\n]*;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/, + ), ) ) GM_config.set("presets-add", presets); }, - false + false, ); GM_config.fields[ "presets-edit-unchecked" @@ -413,7 +413,7 @@ function setupMAULConfig() { function () { const presets = GM_config.get( "presets-edit-unchecked", - true + true, ) as string; if ( @@ -421,13 +421,13 @@ function setupMAULConfig() { .split(/\r?\n/) .every((line) => line.match( - /^[^;\r\n]+;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/ - ) + /^[^;\r\n]+;\d*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*;[^;\r\n]*$/, + ), ) ) GM_config.set("presets-edit", presets); }, - false + false, ); GM_config.fields[ "flag-fields-unchecked" @@ -436,19 +436,19 @@ function setupMAULConfig() { function () { const flagFields = GM_config.get( "flag-fields-unchecked", - true + true, ) as string; if ( flagFields .split(/\r?\n/) .every((line) => - line.match(/^[^;\r\n]+;[^;\r\n]+$/) + line.match(/^[^;\r\n]+;[^;\r\n]+$/), ) ) GM_config.set("flag-fields", flagFields); }, - false + false, ); }, save: function (forgotten) { @@ -458,21 +458,21 @@ function setupMAULConfig() { GM_config.get("presets-add") ) alert( - 'Invalid preset format for "Add Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.' + 'Invalid preset format for "Add Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.', ); if ( forgotten["presets-edit-unchecked"] !== GM_config.get("presets-edit") ) alert( - 'Invalid preset format for "Edit Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.' + 'Invalid preset format for "Edit Ban Presets", value not saved.\nVerify that each line has 6 semicolon-separated values, the preset name is not empty, and that length is either empty or a number > 0.', ); if ( forgotten["flag-fields-unchecked"] !== GM_config.get("flag-fields") ) alert( - 'Invalid flag format for "Flag Fields", value not saved.\nVerify that each line has 2 semicolon-separated values.' + 'Invalid flag format for "Flag Fields", value not saved.\nVerify that each line has 2 semicolon-separated values.', ); } }, @@ -480,7 +480,7 @@ function setupMAULConfig() { css: "textarea {width: 100%; height: 160px; resize: vertical;} #maul-config_field_flag-salt {filter: blur(6px)} #maul-config_field_flag-salt:focus {filter: blur(0)}", }); const dropdownMenu = document.querySelector( - ".user-dropdown > ul.dropdown-menu" + ".user-dropdown > ul.dropdown-menu", ); if (dropdownMenu) { const configButton = document.createElement("li"); @@ -491,7 +491,7 @@ function setupMAULConfig() { configButton.style.cursor = "pointer"; dropdownMenu.insertBefore( configButton, - dropdownMenu.querySelector("li.divider") + dropdownMenu.querySelector("li.divider"), ); } } @@ -515,7 +515,7 @@ function loadAdmins() { function loadUsername() { if (USERNAME) return; const dropdown = document.querySelector( - "a.dropdown-toggle" + "a.dropdown-toggle", ) as HTMLAnchorElement; if (dropdown) USERNAME = dropdown.innerText.trim(); } @@ -616,7 +616,7 @@ function handleAddBan(hash: string = "") { if (preset.length == 0) ( document.getElementById( - "length" + "length", ) as HTMLInputElement ).disabled = true; } @@ -630,10 +630,10 @@ function handleAddBan(hash: string = "") { ).value = preset.notes; ( document.getElementById( - "preventAmnesty" + "preventAmnesty", ) as HTMLInputElement ).checked = preset.pa; - } + }, ); } @@ -643,19 +643,19 @@ function handleAddBan(hash: string = "") { !(document.getElementById("gameId") as HTMLInputElement).disabled ) { const data: AddBan_Data = JSON.parse( - LZString.decompressFromEncodedURIComponent(hash) + LZString.decompressFromEncodedURIComponent(hash), ); if (data.name) (document.getElementById("handle") as HTMLInputElement).value = data.name; if (data.threadId) - ( - document.getElementById("notes") as HTMLTextAreaElement - ).value = `https://edgegamers.com/threads/${data.threadId}/\n\n`; + (document.getElementById("notes") as HTMLTextAreaElement).value = + `https://edgegamers.com/threads/${data.threadId}/\n\n`; (document.getElementById("gameId") as HTMLInputElement).value = data.id; ( document.querySelector("input[name='redirect']") as HTMLInputElement - ).value = `https://maul.edgegamers.com/index.php?page=bans&qType=gameId&q=${data.id}`; + ).value = + `https://maul.edgegamers.com/index.php?page=bans&qType=gameId&q=${data.id}`; } } @@ -681,7 +681,7 @@ function handleEditBan() { if (preset.length == 0) ( document.getElementById( - "length" + "length", ) as HTMLInputElement ).disabled = true; } @@ -698,16 +698,16 @@ function handleEditBan() { (preset.addUsername ? " " + USERNAME : ""); ( document.getElementById( - "preventAmnesty" + "preventAmnesty", ) as HTMLInputElement ).checked = preset.pa; - } + }, ); } // Steam ID buttons const idGroup = document.querySelector( - ".control-label[for=gameId]" + ".control-label[for=gameId]", )?.parentElement; const id = idGroup?.querySelector("p")?.innerText; if (id) { @@ -719,27 +719,30 @@ function handleEditBan() { idDiv.appendChild( createLinkButton( "Steam", - "https://steamcommunity.com/profiles/" + id - ) + "https://steamcommunity.com/profiles/" + id, + ), ); idDiv.appendChild( createLinkButton( "GameME", "https://edgegamers.gameme.com/search?si=uniqueid&rc=all&q=" + - SteamIDConverter.toSteamID(id) - ) + SteamIDConverter.toSteamID(id), + ), ); idDiv.appendChild( - createLinkButton("SteamID (IO)", "https://steamid.io/lookup/" + id) + createLinkButton("SteamID (IO)", "https://steamid.io/lookup/" + id), ); idDiv.appendChild( - createLinkButton("SteamID (UK)", "https://steamid.uk/profile/" + id) + createLinkButton( + "SteamID (UK)", + "https://steamid.uk/profile/" + id, + ), ); } // IP buttons const ipGroup = Array.from( - document.querySelectorAll(".control-label") + document.querySelectorAll(".control-label"), ).find((el) => el.textContent === "IP")?.parentElement; // BECAUSE MAUL HAS THE IP LABELED WITH THE WRONG FOR const ip = ipGroup?.querySelector("p")?.innerText; if (ip) { @@ -754,15 +757,15 @@ function handleEditBan() { GM_config.get("spur-account") ? `https://spur.us/app/context?q=${ip}` : `https://spur.us/context/${ip}`, - "_blank" - ) + "_blank", + ), ); ip_div.appendChild( createLinkButton( "Check IPInfo", "https://ipinfo.io/" + ip, - "_blank" - ) + "_blank", + ), ); } @@ -774,9 +777,9 @@ function handleEditBan() { "div > p.form-control-static, div > input:not(input#preventAmnesty)" + (GM_config.get("flag-ignore-notes") ? "" - : ", div > textarea") - ) - ) + : ", div > textarea"), + ), + ), ).then((arr) => { const insEl = div.parentElement!; const presetHeader = insEl.querySelector("h4"); @@ -784,7 +787,7 @@ function handleEditBan() { const alert = document.createElement("div"); alert.classList.add( "alert", - "alert-" + GM_config.get("flag-alert") + "alert-" + GM_config.get("flag-alert"), ); alert.innerText = result.message; insEl.insertBefore(alert, presetHeader); @@ -815,34 +818,34 @@ function handleProfile() { /(?:https?:\/\/)?(?:www\.)?edge-gamers\.com\/forums\/showthread\.php\?p=(\d+)(?:#?post(\d+))?/g, function (match, threadId, postId) { return generateForumsURL(threadId, postId); - } + }, ) .replaceAll( /(?:https?:\/\/)?(?:www\.)?edge-gamers\.com\/forums\/showthread\.php\?(\d+)[\-a-zA-Z]*/g, function (match, threadId) { return generateForumsURL(threadId, null); - } + }, ) .replaceAll( /https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/=]*)/g, - '$&' + '$&', ) .replaceAll( /([^\/\d]|^)(\d{17})([^\/\d]|$)/g, - '$1$2$3' + '$1$2$3', ); }); // Attempt to get Source ID const sourceIdHref = document.querySelector( - 'span.floatRight > a[href^="https://steamcommunity.com/profiles/"]' + 'span.floatRight > a[href^="https://steamcommunity.com/profiles/"]', ) as HTMLAnchorElement; const id = sourceIdHref.innerText; const btn = createLinkButton( "GameME", "https://edgegamers.gameme.com/search?si=uniqueid&rc=all&q=" + SteamIDConverter.toSteamID(id), - "_blank" + "_blank", ); btn.classList.remove("btn", "btn-default"); sourceIdHref.parentElement?.insertBefore(btn, sourceIdHref); @@ -859,7 +862,7 @@ function handleBanList() { if (GM_config.get("convert-search")) document .querySelector( - "div.form-group.input-group > span.input-group-btn > button" + "div.form-group.input-group > span.input-group-btn > button", ) ?.addEventListener( "click", @@ -867,12 +870,12 @@ function handleBanList() { if ( ( document.getElementById( - "banQType" + "banQType", ) as HTMLSelectElement ).value == "gameId" ) { const searchBox = document.querySelector( - "div.form-group.input-group > input[name='q']" + "div.form-group.input-group > input[name='q']", ) as HTMLInputElement | undefined; const id = searchBox?.value; if (id) { @@ -888,23 +891,23 @@ function handleBanList() { } } }, - false + false, ); if (GM_config.get("flag-enabled")) findFlagFields( Array.from( document.querySelectorAll( - "tbody > tr > td:not(.text-center)" - ) as NodeListOf + "tbody > tr > td:not(.text-center)", + ) as NodeListOf, ).filter( (el) => el.innerText.trim() != "" && - el.parentElement?.style.display != "none" - ) + el.parentElement?.style.display != "none", + ), ).then((arr) => { arr.forEach((result) => { result.element.style.backgroundColor = GM_config.get( - "flag-colour" + "flag-colour", ) as string; result.element.title = result.message; }); @@ -922,7 +925,7 @@ function assignAdminsOnlineHyperlink(str: string) { if (id == undefined) continue; str = str.replace( admin, - `${admin}` + `${admin}`, ); } return str; @@ -934,7 +937,7 @@ function assignAdminsOnlineHyperlink(str: string) { function convertBanningAdmins() { if (Object.keys(knownAdmins).length === 0) loadAdmins(); const headers = document.querySelectorAll( - ".expand > td > span.pull-left" + ".expand > td > span.pull-left", ) as NodeListOf; let wasAdminOnline = false; for (const header of headers) { @@ -954,8 +957,8 @@ function convertBanningAdmins() { function convertGameIDs() { const banIDs = Array.from( document.querySelectorAll( - "table.table-bordered td:not([class]):nth-child(3)" - ) + "table.table-bordered td:not([class]):nth-child(3)", + ), ).filter((el) => !el.querySelector("a")) as HTMLTableCellElement[]; banIDs.forEach((el) => { const id = @@ -971,7 +974,7 @@ function convertGameIDs() { */ function convertDurationFields() { const banDurations = document.querySelectorAll( - "table.table-bordered td:nth-child(5)" + "table.table-bordered td:nth-child(5)", ) as NodeListOf; const convertMinutesToHuman = (minutes: number) => { @@ -1022,7 +1025,7 @@ function convertDurationFields() { const convertedExpiration = moment( (el.parentElement!.firstElementChild as HTMLTableCellElement) - .innerText + .innerText, ) .add(banDuration, "minutes") .format(GM_config.get("datetimeformat-expiration") as string); @@ -1045,7 +1048,7 @@ function convertDurationFields() { * @returns {Array} Elements that match the flagFields */ async function findFlagFields( - elements: Array + elements: Array, ): Promise> { const results: Array = []; for (const el of elements) { @@ -1073,11 +1076,11 @@ function updateBanNoteURLs() { const replaced = unescapedInnerHTML .replaceAll( /https?:\/\/(www\.)?[-a-zA-Z0-9.]{1,256}\.[a-zA-Z0-9]{2,6}\b(\/[-a-zA-Z0-9@:%_\+.~#?&\/=]*)/g, - '$&' + '$&', ) .replaceAll( STEAMID_REGEX, // The most finnicky regex in history, too many false-positives and false-negatives. User configurable for that reason. - '$1$2$3' + '$1$2$3', ); // If the text hasn't been changed, move on if (replaced === unescapedInnerHTML) return; @@ -1095,13 +1098,13 @@ function updateBanNoteURLs() { .original as string; event.target?.removeEventListener( "mousedown", - handleEditNotesClick as EventListener + handleEditNotesClick as EventListener, ); delete (banNote as HTMLSpanElement).dataset.original; } editNotes?.addEventListener( "mousedown", - handleEditNotesClick as EventListener + handleEditNotesClick as EventListener, ); }); } @@ -1120,28 +1123,28 @@ function updateBanNoteURLs() { if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban\/?(?:#.+)?$/ + /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban\/?(?:#.+)?$/, ) ) // Add Ban Page (not Edit, that will have &id=12345 in the URL) handleAddBan(hash.substring(1)); else if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban&id=\d+\/?$/ + /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=editban&id=\d+\/?$/, ) ) // Edit Ban Page handleEditBan(); else if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=home&id=\d+\/?$/ + /^https:\/\/maul\.edgegamers\.com\/index\.php\?page=home&id=\d+\/?$/, ) ) // Profile Page handleProfile(); else if ( url.match( - /^https:\/\/maul\.edgegamers\.com\/index\.php\?.*page=bans.*$/ + /^https:\/\/maul\.edgegamers\.com\/index\.php\?.*page=bans.*$/, ) ) // List Ban Page