diff --git a/source/content-scripts/features/exports.ts b/source/content-scripts/features/exports.ts index 9f730b8..9daed17 100644 --- a/source/content-scripts/features/exports.ts +++ b/source/content-scripts/features/exports.ts @@ -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"; diff --git a/source/content-scripts/features/miscellaneous/hide-own-username.ts b/source/content-scripts/features/miscellaneous/hide-own-username.ts new file mode 100644 index 0000000..20e9930 --- /dev/null +++ b/source/content-scripts/features/miscellaneous/hide-own-username.ts @@ -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( + ".logged-in-user-username", + ); + + loggedInUsername.dataset.trxHideOwnUsername = loggedInUsername.textContent!; + loggedInUsername.textContent = "Username"; +} diff --git a/source/content-scripts/setup.tsx b/source/content-scripts/setup.tsx index b0c85d0..10933a6 100644 --- a/source/content-scripts/setup.tsx +++ b/source/content-scripts/setup.tsx @@ -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 diff --git a/source/options/components/miscellaneous.tsx b/source/options/components/miscellaneous.tsx index 71dbd7c..37aa7e6 100644 --- a/source/options/components/miscellaneous.tsx +++ b/source/options/components/miscellaneous.tsx @@ -33,6 +33,12 @@ function FeatureDescription({ ); } + if (feature === MiscellaneousFeature.HideOwnUsername) { + return ( +

Hide your username for more private browsing.

+ ); + } + if (feature === MiscellaneousFeature.TopicInfoIgnore) { return (

diff --git a/source/storage/enums.ts b/source/storage/enums.ts index aaf6e77..6f70e83 100644 --- a/source/storage/enums.ts +++ b/source/storage/enums.ts @@ -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", }