Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions source/features/hide-useless-comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,28 @@ function unhide(event: delegate.Event<MouseEvent, HTMLButtonElement>): void {
comment.hidden = false;
}

// Expand all "similar comments" boxes
for (const similarCommentsExpandButton of select.all('.js-discussion .Details-content--closed > span:only-child')) {
Copy link
Member

@fregante fregante Feb 23, 2021

Choose a reason for hiding this comment

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

Maybe

Suggested change
for (const similarCommentsExpandButton of select.all('.js-discussion .Details-content--closed > span:only-child')) {
for (const similarCommentsExpandButton of select.all('.pagination-loader-container .Details-content--closed > span:only-child')) {

Copy link
Member

Choose a reason for hiding this comment

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

We should fix this soon and I'll release an early version

similarCommentsExpandButton.click();
}

select('.rgh-hidden-comment')!.scrollIntoView();
event.delegateTarget.parentElement!.remove();
}

function hideComment(comment: HTMLElement): void {
comment.hidden = true;
comment.classList.add('rgh-hidden-comment');
}

function init(): void {
let uselessCount = 0;

for (const similarCommentsBox of select.all('.js-discussion .Details-element')) {
hideComment(similarCommentsBox);
uselessCount++;
}

for (const commentText of select.all('.comment-body > p:only-child')) {
if (!isUselessComment(commentText.textContent!)) {
continue;
Expand All @@ -43,8 +59,7 @@ function init(): void {
continue;
}

comment.hidden = true;
comment.classList.add('rgh-hidden-comment');
hideComment(comment);
uselessCount++;
}

Expand Down