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

Function addConversationBanner

source/features/rgh-netiquette.tsx:13–57  ·  view source on GitHub ↗
(newCommentBox: HTMLElement)

Source from the content-addressed store, hash-verified

11import {getCloseDate, getResolvedText, wasLongAgo} from './netiquette.js';
12
13async function addConversationBanner(newCommentBox: HTMLElement): Promise<void> {
14 // Check inside the observer because React views load after dom-ready
15 const closingDate = await getCloseDate();
16 if (!closingDate || !wasLongAgo(closingDate)) {
17 features.unload(import.meta.url);
18 return;
19 }
20
21 const button = (
22 <button
23 type="button"
24 className="btn-link"
25 onClick={() => {
26 newCommentBox.hidden = false;
27
28 // Keep the banner, make it visible
29 closestElement('.rgh-bg-none', button).classList.replace('rgh-bg-none', 'flash-error');
30
31 // Unlink this button
32 button.replaceWith(button.firstChild!);
33
34 newCommentBox.scrollIntoView({
35 behavior: 'smooth',
36 });
37 }}
38 >
39 comment
40 </button>
41 );
42
43 const banner = (
44 <TimelineItem>
45 {createBanner({
46 classes: ['rgh-bg-none'],
47 icon: <InfoIcon className="mr-1 tmp-mr-1" />,
48 text: <>
49 {getResolvedText(closingDate)} If you want to say something helpful, you can leave a {button}.{' '}
50 <strong>Do not</strong> report issues here.
51 </>,
52 })}
53 </TimelineItem>
54 );
55 newCommentBox.before(banner);
56 newCommentBox.hidden = true;
57}
58
59function init(signal: AbortSignal): void | false {
60 observe(

Callers

nothing calls this directly

Calls 5

getCloseDateFunction · 0.85
wasLongAgoFunction · 0.85
createBannerFunction · 0.85
getResolvedTextFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected