Skip to content

Hide the message button on your own profile - #1061

Merged
boomzero merged 4 commits into
devfrom
hide-self-mail-button
Oct 6, 2026
Merged

boomzero merged 4 commits into
devfrom
hide-self-mail-button

Conversation

@boomzero

@boomzero boomzero commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What does this PR aim to accomplish?:

Closes #1060. Viewing your own profile shows a "短消息" button that would send a message to yourself.

How does this PR accomplish the above?:

The native userinfo.php caption is admin--高老师<a href=mail.php?to_user=admin>短消息</a>. InitializeUserProfile moves every caption link into the new profile header. It now skips the mail.php link when the profile's user ID equals CurrentUsername; the skipped link is discarded along with the caption on the next line. Other users' profiles are unchanged.


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributor's guide, as well as this entire template.
  2. I have commented on my proposed changes within the code.
  3. I have tested my changes. (Syntax-checked with node --check and confirmed the native caption markup on the live site; not yet exercised in a browser.)
  4. I am willing to help maintain this change if there are issues with it later.
  5. It is compatible with the GNU General Public License v3.0.
  6. I have squashed any insignificant commits.
  7. I have checked that another pull request for this purpose does not exist.
  8. I have considered and confirmed that this submission will be valuable to others.
  9. I accept that this submission may not be used, and the PR can be closed at the will of the maintainer.
  10. I give this submission freely and claim no ownership to its content.
  11. ⚠️ Needs human verification: not yet checked in both the new UI and the old/classic UI.

  • I have read the above and my PR is ready for review.

🤖 Generated with Claude Code

https://claude.ai/code/session_017dqWu3YgeVRGwBt5pXDq4A

Summary by Sourcery

Prevent users from being offered a message action on their own profile while preserving messaging for other users.

Bug Fixes:

  • Hide the self-messaging button when viewing the current user's own profile.

Build:

  • Bump the userscript and package versions to 4.0.2.

Chores:

  • Add update metadata for the 4.0.2 release.

The native userinfo.php caption contains a mail.php?to_user= link that
InitializeUserProfile moved into the profile header for every user,
including yourself. Skip it when the profile belongs to the current user.

Closes #1060

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017dqWu3YgeVRGwBt5pXDq4A
@sourcery-ai

sourcery-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Sorry @boomzero, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 4 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates InitializeUserProfile to hide the “短消息” button on a user’s own profile by filtering the native mail.php caption link during header construction, while preserving messaging controls on other profiles.

Sequence diagram for hiding the self-message profile button

sequenceDiagram
    participant User
    participant InitializeUserProfile
    participant NativeProfile
    participant ProfileHeader

    User->>InitializeUserProfile: InitializeUserProfile()
    InitializeUserProfile->>NativeProfile: querySelectorAll(a)
    alt userID == CurrentUsername and href includes mail.php
        InitializeUserProfile-->>ProfileHeader: Skip mail.php link
        InitializeUserProfile->>NativeProfile: remove caption
    else Other profile or non-mail link
        InitializeUserProfile->>ProfileHeader: appendChild(link)
        InitializeUserProfile->>NativeProfile: remove caption
    end
Loading

File-Level Changes

Change Details Files
Suppress the self-message link when constructing the profile header.
  • Iterate over caption links before moving them into the new header.
  • Skip links targeting mail.php when the viewed user matches CurrentUsername.
  • Continue moving all links for other users, then remove the original caption.
XMOJ.user.js

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T11:07:23.456124Z f6e836c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hendragon-bot hendragon-bot Bot added the user-script This issue or pull request is related to the main user script label Oct 6, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Deploying xmoj-script-dev-channel with  Cloudflare Pages  Cloudflare Pages

Latest commit: 09b80aa
Status: ✅  Deploy successful!
Preview URL: https://20689409.xmoj-script-dev-channel.pages.dev
Branch Preview URL: https://hide-self-mail-button.xmoj-script-dev-channel.pages.dev

View logs

@pull-request-size pull-request-size Bot added size/S and removed size/XS labels Oct 6, 2026
@boomzero
boomzero merged commit f58e426 into dev Oct 6, 2026
3 of 4 checks passed
@boomzero
boomzero deleted the hide-self-mail-button branch October 6, 2026 11:06

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S user-script This issue or pull request is related to the main user script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant