Skip to content

Commit

Permalink
πŸ› Fix broken comment form. Fixes #168
Browse files Browse the repository at this point in the history
  • Loading branch information
jerone committed Feb 12, 2024
1 parent 71295c0 commit 42608eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Github_Reply_Comments/Github_Reply_Comments.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// @updateURL https://github.com/jerone/UserScripts/raw/master/Github_Reply_Comments/Github_Reply_Comments.user.js
// @supportURL https://github.com/jerone/UserScripts/issues
// @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VCYMHWQ7ZMBKW
// @version 1.0.5
// @version 1.0.6
// @icon https://github.githubassets.com/pinned-octocat.svg
// @grant none
// @include https://github.com/*
Expand Down Expand Up @@ -59,7 +59,7 @@
}

var textareas = newComment.querySelectorAll(
":scope > :not(.last-review-thread) .comment-form-textarea:not(.github-writer-ckeditor)",
":scope > :not(.last-review-thread) .js-comment-field:not(.github-writer-ckeditor)",
);
return textareas[textareas.length - 1];
}
Expand All @@ -68,7 +68,7 @@
var commentText = "";

// Use raw comment when available.
var commentForm = comment.querySelector(".comment-form-textarea");
var commentForm = comment.querySelector(".js-comment-field");
if (commentForm) {
commentText = commentForm.value;
}
Expand All @@ -88,6 +88,14 @@
},
);

// Refined GitHub adds a small avatar to username mention. See https://github.com/refined-github/refined-github/blob/main/source/features/small-user-avatars.tsx
Array.prototype.forEach.call(
commentBody.querySelectorAll(".rgh-small-user-avatars"),
function (rgh) {
rgh.remove();
},
);

// GitHub add an extra new line, which is converted by Turndown.
Array.prototype.forEach.call(
commentBody.querySelectorAll("pre code"),
Expand Down
4 changes: 4 additions & 0 deletions Github_Reply_Comments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ reply button on an comment.

## Version History

- version **1.0.6**

- πŸ› Fix broken comment form. Fixes ([#168](https://github.com/jerone/UserScripts/issues/168)).

- version **1.0.5**

- πŸ› Enable the Comment button. Fixes ([#152](https://github.com/jerone/UserScripts/issues/152)).
Expand Down

0 comments on commit 42608eb

Please sign in to comment.