blob: 5b71a331a1dd50e8731dad1152d99afccaacf7b8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import select from 'select-dom';
import features from '../libs/features';
import * as icons from '../libs/icons';
function init(): void {
const menuItems = select.all('details .js-comment-edit-button:not(.rgh-edit-comment)');
for (const item of menuItems) {
item.classList.add('rgh-edit-comment');
const button = item.cloneNode() as HTMLButtonElement;
button.append(icons.edit());
button.classList.replace('dropdown-item', 'timeline-comment-action');
item.closest('details')!.before(button);
// Hide `Edit` from dropdown
item.hidden = true;
if (
item.matches(':last-child') &&
item.previousElementSibling &&
item.previousElementSibling.matches('.dropdown-divider')
) {
item.previousElementSibling.remove();
} else if (
item.previousElementSibling &&
item.previousElementSibling.matches('.dropdown-divider') &&
item.nextElementSibling &&
item.nextElementSibling.matches('.dropdown-divider')
) {
item.nextElementSibling.remove();
}
}
}
features.add({
id: __featureName__,
description: 'Moves the `Edit comment` button out of the `...` dropdown.',
screenshot: 'https://user-images.githubusercontent.com/1402241/54864831-92372a00-4d97-11e9-8c29-efba2dde1baa.png',
include: [
features.hasComments
],
load: features.onNewComments,
init
});
|