Skip to content

feat(comments): search loaded comments, newest-first and expand all replies (#4084) - #4488

Open
chirag127 wants to merge 3 commits into
code-charity:masterfrom
chirag127:feat/comments-tools
Open

chirag127 wants to merge 3 commits into
code-charity:masterfrom
chirag127:feat/comments-tools

Conversation

@chirag127

@chirag127 chirag127 commented Nov 16, 2026 •

Copy link
Copy Markdown

Part of #4084 — search, newest-first ordering and expand-all. The translate bullet from the issue is not included.

What this adds

Three independent switches under Appearance → Comments tools:

Switch Behaviour
Search loaded comments A search bar above the comments; non-matching threads are hidden (display:none) and restored when the query is cleared. Escape clears it.
Sort by newest first Opens YouTube's own sort menu and picks the item whose label means "newest", once per video.
Expand all replies Clicks every visible "N replies" button, then two follow-up passes for the replies those clicks render.

Nothing is written to YouTube: search only hides loaded threads, and the other two click controls YouTube already provides.

Why this shape

  • Comments are infinite; a client-side filter can only search what is loaded. The bar says 3 / 20 rather than pretending to search all 2.4 million comments.
  • Sorting is done by YouTube (its menu), not by re-ordering DOM. That keeps continued pagination consistent.
  • The sort item is matched by text with English plus common translations (newest|最新|nuevos|récent|neueste|新しい|최신); if no item matches, nothing is clicked.

Where it lives

File Change
js&css/web-accessible/www.youtube.com/features/comments-tools.js new module
menu/skeleton-parts/comments-tools.js new card under Appearance
_locales/en/messages.json four keys
manifest.json, js&css/extension/init.js, menu/index.html one line each
tests/unit/comments-tools.test.js 4 tests

No existing feature file is edited. All three switches default off.

Verification

$ npx jest tests/unit/comments-tools.test.js
Tests: 4 passed, 4 total
  - case-insensitive match
  - empty query matches everything
  - newest-first lookup in English and translated labels
  - no newest item -> -1

$ npx jest
Test Suites: 40 passed, 40 total
Tests:       243 passed, 243 total

$ ESLINT_USE_FLAT_CONFIG=true npx eslint --config=tests/eslint_rules.config.mjs \
    "js&css/web-accessible/www.youtube.com/features/comments-tools.js"
0 errors

Live on youtube.com/watch?v=dQw4w9WgXcQ in Chrome 157, comments loaded (20 threads):

bar present, initial count "20 loaded"
typed "meme" -> "3 / 20", 17 threads hidden

Comment search

Not tested live

  • The sort and expand switches were not clicked in the live browser: both drive YouTube's UI and a locale-dependent menu, and clicking them changes the session's comment order / triggers reply pagination. Their pure lookup helper is unit-tested, and both paths are guarded so a missing control does nothing.
  • Firefox/Safari.

Conflicts

No open PR touches these new files. There are five open PRs around comments, but they change the comments sidebar, comment menus and Shorts comment overlay; none adds a filter or drives the sort menu. Shared edits are one line each.

Adds three independent switches under Appearance -> Comments tools.
Search hides non-matching threads and restores them on clear; the
other two drive YouTube's own sort menu and reply buttons.
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.

1 participant