From 3df5a07ae0f85f1cbec5f2e8b9aacec20f91c582 Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Tue, 3 May 2022 18:52:18 +0100 Subject: [PATCH] Grab container only when initialising As the tab is destroyed when swapping, the container is no longer part of the DOM if grabbed too early. --- Reputation Investigation/src/ReputationInvestigation.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Reputation Investigation/src/ReputationInvestigation.ts b/Reputation Investigation/src/ReputationInvestigation.ts index 335ab9b..b44d52b 100644 --- a/Reputation Investigation/src/ReputationInvestigation.ts +++ b/Reputation Investigation/src/ReputationInvestigation.ts @@ -115,12 +115,12 @@ $(() => { const reputationPageLink = /tab=reputation/; const tabSelectedRegex = /&sort=detailed/; - const container = $('#rep-page-container'); - function addUiItems() { const detailedLink = $(`Detailed`); const initialize = () => { + const container = $('#rep-page-container'); + $('.js-user-tab-sorts a').removeClass('is-selected'); $(detailedLink).addClass('is-selected'); @@ -161,7 +161,7 @@ $(() => { $('.js-user-tab-sorts').append(detailedLink); } else { const initSocky = () => { - if (!container.length) { + if (!$('#rep-page-container').length) { setTimeout(initSocky, 500); } else { initialize();