forked from honestbleeps/Reddit-Enhancement-Suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommentSortBy.js
32 lines (28 loc) · 888 Bytes
/
commentSortBy.js
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
/* @flow */
import { Module } from '../core/module';
import {
string,
watchForRedditEvents,
} from '../utils';
export const module: Module<*> = new Module('commentSortBy');
module.moduleName = 'commentSortByTitle';
module.category = 'commentsCategory';
module.description = 'commentSortByDesc';
module.include = ['d2x'];
module.beforeLoad = () => {
watchForRedditEvents('postModTools', (element, { _: { update } }) => {
if (update) return;
const _base = document.querySelector('#CommentSort--SortPicker');
const base = _base && _base.parentElement;
if (!base || base.querySelector('.sortByPrefLink')) return;
base.append(string.html`
<a
class="sortByPrefLink gearIcon"
style="opacity: 0.3;"
title="Go to comment sort preferences"
href="https://old.reddit.com/prefs/#default_comment_sort"
target="_blank"
>${'\u00A0'/* nbsp */}</a>
`);
});
};