message: Enable `quick-mention` in more places
diff: @@ -32,28 +32,36 @@ function mentionUser({delegateTarget: button}: DelegateEvent): void {
  textFieldEdit.insert(newComment, `${spacer}${prefixUserMention(userMention)} `);
  }
  -function init(signal: AbortSignal): void {
  - delegate(document, 'button.rgh-quick-mention', 'click', mentionUser, {signal});
  +const debug = false;
  - // `:first-child` avoids app badges #2630
  - // The hovercard attribute avoids `highest-rated-comment`
  - // Avatars next to review events aren't wrapped in a <div> #4844
  - observe(`
  - :is(
  - div.TimelineItem-avatar > [data-hovercard-type="user"]:first-child,
  - a.TimelineItem-avatar
  - ):not([href="/${getUsername()!}"])
  - `, avatar => {
  - const timelineItem = avatar.closest('.TimelineItem')!;
  +function add(avatar: HTMLElement): void {
  + if (debug) {
  + avatar.style.border = 'solid 5px black';
  + }
  +
  + const timelineItem = avatar.closest([
  + // Regular comments
  + '.js-comment-container',
  +
  + // Reviews
  + '.js-comment',
  + ])!;
  + if (debug) {
  + timelineItem.style.border = 'solid 5px red';
  + }
  if (
  // TODO: Rewrite with :has()
  - select.exists('.minimized-comment', timelineItem) // Hidden comments
  - || !select.exists('.timeline-comment', timelineItem) // Reviews without a comment
  + // Exclude events that aren't tall enough, like hidden comments or reviews without comments
  + !select.exists('.unminimized-comment, .js-comment-container', timelineItem)
  ) {
  return;
  }
  + if (debug) {
  + timelineItem.style.border = 'solid 5px green';
  + }
  +
  // Wrap avatars next to review events so the inserted button doesn't break the layout #4844
  if (avatar.classList.contains('TimelineItem-avatar')) {
  avatar.classList.remove('TimelineItem-avatar');
  @@ -71,7 +79,20 @@ function init(signal: AbortSignal): void {
  <ReplyIcon/>
  </button>,
  );
  - }, {signal});
  +}
  +
  +function init(signal: AbortSignal): void {
  + delegate(document, 'button.rgh-quick-mention', 'click', mentionUser, {signal});
  +
  + // `:first-child` avoids app badges #2630
  + // The hovercard attribute avoids `highest-rated-comment`
  + // Avatars next to review events aren't wrapped in a <div> #4844
  + observe(`
  + :is(
  + div.TimelineItem-avatar > [data-hovercard-type="user"]:first-child,
  + a.TimelineItem-avatar
  + ):not([href="/${getUsername()!}"])
  + `, add, {signal});
  }
  void features.add(import.meta.url, {
  @@ -86,3 +107,14 @@ void features.add(import.meta.url, {
  // awaitDomReady: false,
  init,
  });
  +
  +/*
  +
  +Test URLs
  +
  +https://github.com/refined-github/sandbox/pull/10
  +
  +No-comment reviews shouldn't have it:
  +https://github.com/NixOS/nixpkgs/pull/147010#pullrequestreview-817111882
  +
  +*/
  