MCPcopy Index your code
hub / github.com/refined-github/refined-github / preview

Function preview

source/features/preview-hidden-comments.tsx:11–36  ·  view source on GitHub ↗
(hiddenCommentHeader: HTMLElement)

Source from the content-addressed store, hash-verified

9import observe from '../helpers/selector-observer.js';
10
11function preview(hiddenCommentHeader: HTMLElement): void {
12 const details = closestElement('details', hiddenCommentHeader);
13 details.classList.add('rgh-preview-hidden-comments'); // Used in CSS
14
15 const comment = $('.comment-body', details);
16 const commentText = comment.textContent.trim();
17 if (commentText.length === 0) {
18 return;
19 }
20
21 const commentHeader = hiddenCommentHeader.textContent;
22 if (/disruptive|spam/.test(commentHeader)) {
23 return;
24 }
25
26 // The reason is missing/lost in some cases
27 const reason = /duplicate|outdated|off-topic|hidden/.exec(commentHeader)?.[0];
28 hiddenCommentHeader.classList.add('css-truncate', 'css-truncate-overflow', 'mr-2');
29 hiddenCommentHeader.append(
30 <span className="Details-content--open">{hiddenCommentHeader.firstChild}</span>,
31 <span className="Details-content--closed">
32 {reason && <span className="Label mr-2 tmp-mr-2">{upperCaseFirst(reason)}</span>}
33 {commentText.slice(0, 100)}
34 </span>,
35 );
36}
37
38function init(signal: AbortSignal): void {
39 // `.timeline-comment-group` excludes review comments, which are always loaded on click, so it's not possible to preview them

Callers

nothing calls this directly

Calls 2

upperCaseFirstFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected