From 1493b2c96b0ab67710fccc7584aa36f1d92461a0 Mon Sep 17 00:00:00 2001 From: Bauke Date: Thu, 24 Feb 2022 13:46:51 +0100 Subject: [PATCH] Make autocomplete aware of anonymous usernames. --- source/scripts/autocomplete.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/scripts/autocomplete.ts b/source/scripts/autocomplete.ts index 18429b7..bf58de3 100644 --- a/source/scripts/autocomplete.ts +++ b/source/scripts/autocomplete.ts @@ -30,11 +30,16 @@ export class AutocompleteFeature extends Component { ); // Get all the usernames on the page without their leading @s, and get - // all the username from the saved user labels. + // all the usernames from the saved user labels. + const usernameElements = querySelectorAll('.link-user'); const usernames = [ - ...querySelectorAll('.link-user').map((value) => - value.textContent!.replace(/^@/, '').toLowerCase(), - ), + ...usernameElements.map((value) => { + if (props.settings.features.anonymizeUsernames) { + return (value.dataset.trxUsername ?? '').toLowerCase(); + } + + return value.textContent!.replace(/^@/, '').toLowerCase(); + }), ...props.settings.data.userLabels.map((value) => value.username), ].sort((a, b) => a.localeCompare(b));