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 "./markdown-toolbar.js";
export * from "./miscellaneous/comment-anchor-fix.js"; export * from "./miscellaneous/comment-anchor-fix.js";
export * from "./miscellaneous/group-list-subscribe-button.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/topic-info-ignore.js";
export * from "./miscellaneous/unignore-all-button.js"; export * from "./miscellaneous/unignore-all-button.js";
export * from "./themed-logo.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, runAnonymizeUsernamesFeature,
runCommentAnchorFixFeature, runCommentAnchorFixFeature,
runGroupListSubscribeButtonFeature, runGroupListSubscribeButtonFeature,
runHideOwnUsernameFeature,
runHideTopicsFeature, runHideTopicsFeature,
runHideVotesFeature, runHideVotesFeature,
runMarkdownToolbarFeature, runMarkdownToolbarFeature,
@ -173,6 +174,13 @@ async function initialize() {
runGroupListSubscribeButtonFeature(); runGroupListSubscribeButtonFeature();
} }
if (
miscEnabled.value.has(MiscellaneousFeature.HideOwnUsername) &&
isLoggedIn
) {
runHideOwnUsernameFeature();
}
if ( if (
miscEnabled.value.has(MiscellaneousFeature.TopicInfoIgnore) && miscEnabled.value.has(MiscellaneousFeature.TopicInfoIgnore) &&
isLoggedIn 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) { if (feature === MiscellaneousFeature.TopicInfoIgnore) {
return ( return (
<p class="description"> <p class="description">

View File

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