1
Fork 0

Add a miscellaneous feature for hiding your own username.

This commit is contained in:
Bauke 2023-08-29 12:54:30 +02:00
parent 01d882989b
commit ee768cfd41
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
5 changed files with 31 additions and 0 deletions

View File

@ -7,6 +7,7 @@ export * from "./jump-to-new-comment.js";
export * from "./markdown-toolbar.js";
export * from "./miscellaneous/comment-anchor-fix.js";
export * from "./miscellaneous/group-list-subscribe-button.js";
export * from "./miscellaneous/hide-own-username.js";
export * from "./miscellaneous/topic-info-ignore.js";
export * from "./miscellaneous/unignore-all-button.js";
export * from "./themed-logo.js";

View File

@ -0,0 +1,15 @@
import {log, querySelector} from "../../../utilities/exports.js";
export function runHideOwnUsernameFeature(): void {
hideOwnUsername();
log("Username has been hidden.");
}
function hideOwnUsername(): void {
const loggedInUsername = querySelector<HTMLElement>(
".logged-in-user-username",
);
loggedInUsername.dataset.trxHideOwnUsername = loggedInUsername.textContent!;
loggedInUsername.textContent = "Username";
}

View File

@ -19,6 +19,7 @@ import {
runAnonymizeUsernamesFeature,
runCommentAnchorFixFeature,
runGroupListSubscribeButtonFeature,
runHideOwnUsernameFeature,
runHideTopicsFeature,
runHideVotesFeature,
runMarkdownToolbarFeature,
@ -173,6 +174,13 @@ async function initialize() {
runGroupListSubscribeButtonFeature();
}
if (
miscEnabled.value.has(MiscellaneousFeature.HideOwnUsername) &&
isLoggedIn
) {
runHideOwnUsernameFeature();
}
if (
miscEnabled.value.has(MiscellaneousFeature.TopicInfoIgnore) &&
isLoggedIn

View File

@ -33,6 +33,12 @@ function FeatureDescription({
);
}
if (feature === MiscellaneousFeature.HideOwnUsername) {
return (
<p class="description">Hide your username for more private browsing.</p>
);
}
if (feature === MiscellaneousFeature.TopicInfoIgnore) {
return (
<p class="description">

View File

@ -22,6 +22,7 @@ export enum Feature {
export enum MiscellaneousFeature {
CommentAnchorFix = "comment-anchor-fix",
GroupListSubscribeButtons = "group-list-subscribe-buttons",
HideOwnUsername = "hide-own-username",
TopicInfoIgnore = "topic-info-ignore",
UnignoreAllButton = "unignore-all-button",
}