Skip to content

Filter comments toggle, X on phones, and m.youtube.com - #3

Merged
tshmieldev merged 3 commits into
mainfrom
tshmieldev/commentsandmobilestuff
Sep 18, 2026
Merged

tshmieldev merged 3 commits into
mainfrom
tshmieldev/commentsandmobilestuff

Conversation

@tshmieldev

@tshmieldev tshmieldev commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Comment filtering becomes opt-in, Sharp's X controls now work at phone widths, and the YouTube rules apply on m.youtube.com. Tested on Kiwi (Android).

Filter comments

A new toggle under X › Filtering, off by default.

  • Off: replies under a post are left alone. Only the timeline is filtered.
  • On: replies are judged like any other post. This was the behaviour before this change.
  • The post you opened, and everything it replies to, always shows.
  • Off means no reply on a post page is hidden, blocked authors included. This matches what "Show all comments in this thread" already did. Blocked authors are still hidden on the timeline.

The in-thread button only appears while comments are filtered, since otherwise there's nothing for it to switch off. When on, it now describes the current state ("✓ Showing all comments in this thread") instead of the next action ("Filter comments in this thread").

X on phones

Both fixes come from DOM captures on Kiwi, which are the fixtures for the new tests.

⋯ menu. At phone width X shows the post menu as a bottom sheet ([data-testid="sheetDialog"]) instead of a dropdown, with no role="menu" around it and a Cancel button last. Sharp didn't recognise it, so "Never filter / Always hide / Hide posts like this" never appeared. Now:

  • The sheet is recognised, and Sharp's rows go just above Cancel.
  • Sharp still works out which post and author the menu is for from the "View post activity" link, which must match "Block @x". X's other sheets (repost, share) don't have that link, so they're left alone.
  • After an action the sheet is closed with Escape. If it's still open a frame later, Sharp taps its backdrop, so it's never closed twice.

Thread button. Phone thread pages have no inline reply box to sit above. The fallback places the button at the top of the replies, inside the first reply's cell so X still measures it. It first has to skip the empty cell X places right after the opened post; the previous fallback stopped there, which is why the button didn't appear.

YouTube on phones

The YouTube rules now apply on m.youtube.com as well as www.youtube.com. Sharp doesn't read or change YouTube's page logic; it sets attributes on the page and a stylesheet does the hiding. So supporting the mobile site meant adding its hostname and some CSS selectors:

  • The hostname is added everywhere Sharp lists the sites it runs on: the manifest's permissions and matches, the content-script dispatcher, the worker's trusted senders, and the popup's site detection and origin list.
  • Selectors cover the mobile site's ytm- elements, alongside the desktop ytd- ones. That includes the Shorts entry in the bottom tab bar.
  • A test now checks that the popup's origin list matches the manifest's content-script matches, both ways. On Firefox, a site missing from that list would be one Sharp never asks permission for, so its content script would silently never run.
  • Hostnames are matched exactly: music.youtube.com, studio.youtube.com and lookalikes such as m.youtube.com.evil.test start nothing.

The mobile selectors haven't been checked against every page yet. Hidden thumbnails are the most layout-dependent rule.

Popup

  • Greyscale moved out of the Filtering tabs into a Misc tab, for both X and YouTube.
  • The Filter comments toggle keeps only its short description.

Testing

  • bun run check passes: types, 83 tests, formatting, and both Chrome and Firefox builds.
  • 11 new tests, covering the rule, both thread layouts, the spacer cell, the sheet and the sheets Sharp should ignore. Each fix was reverted to check its test fails without it.
  • On Kiwi: the sheet rows appear and save, and the thread button appears and works with Filter comments on.

Filter comments, off by default. Replies under a post are left alone unless the
reader asks for them to be judged; the timeline is filtered either way, and the
opened post and its ancestors always show. Off is absolute, like a bypassed
thread: blocked authors in replies show too. The "Show all comments in this
thread" control only appears while comments are filtered, since otherwise there
is nothing for it to switch off.

At phone widths X shows the post menu as a bottom sheet (sheetDialog) with no
menu role around it and its own Cancel button last. Sharp now recognises it and
places its rows above Cancel. The post is still identified by the engagements
link, which X's other sheets do not carry, so they stay untouched. A sheet may
ignore Escape, so if it is still open a frame after an action, its backdrop is
tapped to close it.

Where a thread page has no inline reply box, the thread control goes at the top
of the replies, inside the first reply's cell so X still measures it.

Structure for the sheet and thread fixtures comes from a Kiwi capture. Not yet
checked on a device: tapping a row, the sheet's scroll, and the reply fallback.
The thread control's phone fallback stopped at the empty cell X places right
after the opened post, so on layouts without an inline reply box the button
never appeared. Empty cells are now stepped over on the way to the first reply.

Greyscale moves out of the filtering tabs into a Misc tab of its own, for X
and for YouTube. The Filter comments toggle keeps only its short description.
The thread button, when on, now says what it is doing rather than what tapping
it again would do: "Showing all comments in this thread".
Copilot AI lite review requested due to automatic review settings September 18, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: f60469c9-d18d-47f6-88d8-d3057203fbd9

📥 Commits

Reviewing files that changed from the base of the PR and between 09de756 and 0cf865d.

📒 Files selected for processing (19)
  • CONTRIBUTING.md
  • README.md
  • manifest.json
  • privacy-policy.md
  • src/background/index.ts
  • src/common/settings.ts
  • src/index.ts
  • src/popup/App.tsx
  • src/popup/XPanel.tsx
  • src/popup/YouTubePanel.tsx
  • src/x/post-menu-dom.ts
  • src/x/post-menu.ts
  • src/x/rules.ts
  • src/x/thread-control.tsx
  • src/youtube/style.css
  • tests/comments.test.ts
  • tests/manifest.test.ts
  • tests/post-menu.test.ts
  • tests/youtube.test.ts
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

The YouTube adapter never looked at the page: it sets attributes on <html> and
the stylesheet decides what they mean. So the mobile site cost selectors rather
than code, plus the hostname in the five places that list where Sharp runs —
the manifest's permissions and matches, the content-script dispatcher, the
worker's trusted senders, and the popup's site detection and origin list.

Mobile serves `ytm-` Polymer elements where the desktop site serves `ytd-`, and
puts navigation in a bar along the bottom rather than a sidebar. The newer
`*-view-model` elements and `yt*ViewModel` classes are shared and were already
covered. A selector matching nothing on the site in front of it costs nothing,
so each feature's desktop and mobile selectors sit together.

The origin list and the manifest are now checked against each other in both
directions. A site injected into but not listed is a content script that never
runs on Firefox, where host permissions are granted one origin at a time, and
the popup would have no way to ask for it.

Hostnames are still matched exactly, so music.youtube.com and a lookalike like
m.youtube.com.evil.test start nothing. That is now tested.

The mobile selectors are written from the shape of the mobile site, not from a
session against it; they want checking on a real device before release.
@tshmieldev tshmieldev changed the title Filter comments toggle, and X's controls on phones Filter comments toggle, X on phones, and m.youtube.com Sep 18, 2026
@tshmieldev
tshmieldev merged commit 36d69a1 into main Sep 18, 2026
2 of 3 checks passed
@tshmieldev
tshmieldev deleted the tshmieldev/commentsandmobilestuff branch September 18, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants