Skip to content

Commit 001de34

Browse files
committed
Enable the Comment button. Fixes #152
1 parent 7f9095b commit 001de34

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Github_Reply_Comments/Github_Reply_Comments.user.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
});
3232
};
3333

34-
var turndownService = new TurndownService({ headingStyle: 'atx', codeBlockStyle: 'fenced', hr: '***' });
34+
var turndownService = new TurndownService({
35+
headingStyle: 'atx',
36+
codeBlockStyle: 'fenced',
37+
hr: '***'
38+
});
3539
turndownService.use(turndownPluginGfm.gfm);
3640
turndownService.use(turndownPluginGithubCodeSnippet);
3741

@@ -46,7 +50,7 @@
4650
inlineComment.classList.add("open");
4751
}
4852

49-
var textareas = newComment.querySelectorAll(":scope > :not(.last-review-thread) .comment-form-textarea");
53+
var textareas = newComment.querySelectorAll(":scope > :not(.last-review-thread) .comment-form-textarea:not(.github-writer-ckeditor)");
5054
return textareas[textareas.length - 1];
5155
}
5256

@@ -120,8 +124,8 @@
120124

121125
var newComment = getCommentTextarea(this);
122126

123-
var author = comment.querySelector(".author");
124-
var authorLink = location.origin + (author.getAttribute("href") || "/" + author.textContent);
127+
var author = comment.querySelector(".author");
128+
var authorLink = location.origin + (author.getAttribute("href") || "/" + author.textContent);
125129

126130
var text = newComment.value.length > 0 ? "\n" : "";
127131
text += String.format('[**@{0}**]({1}) commented on [{2}]({3} "{4} - Replied by Github Reply Comments"):\n{5}\n\n',
@@ -134,7 +138,14 @@
134138

135139
newComment.value += text;
136140
newComment.setSelectionRange(newComment.value.length, newComment.value.length);
141+
//newComment.closest('.previewable-comment-form').querySelector('.js-write-tab').click();
137142
newComment.focus();
143+
144+
// This will enable the "Comment" button, when there was no comment text yet.
145+
newComment.dispatchEvent(new CustomEvent('change', {
146+
bubbles: true,
147+
cancelable: false
148+
}));
138149
});
139150

140151
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");

0 commit comments

Comments
 (0)