-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhideCheckboxes.js
More file actions
47 lines (42 loc) · 1.32 KB
/
hideCheckboxes.js
File metadata and controls
47 lines (42 loc) · 1.32 KB
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
45
46
47
import eventManager from 'src/utils/eventManager.js';
import * as settings from 'src/utils/settings/index.js';
import style from 'src/utils/style.js';
import Translation from 'src/structures/constants/translation';
import { crafting, decks } from './filter.js';
import { getTranslationArray } from '../underscript/translation.js';
const setting = settings.register({
key: 'underscript.library.hidebuttons',
name: Translation.Setting('filter.trim'),
options() {
const { key } = Translation.Setting('filter.trim.option');
const array = getTranslationArray(key);
return ['Always', 'Deck', 'Crafting', 'Never'].map(
(val, i) => [array[i], val],
);
},
page: 'Library',
category: Translation.Setting('category.filter'),
onChange: refresh,
});
const styles = style.add();
function apply() {
switch (setting.value()) {
case 'Always': return decks || crafting;
case 'Deck': return decks;
case 'Crafting': return crafting;
case 'Never':
default: return false;
}
}
function refresh() {
if (apply()) {
styles.replace(
'.filter input { display: none; }',
'.filter input+* { margin: 0 2px; opacity: 0.2; }',
'.filter .rainbowText { padding: 0px 5px; font-size: 22px; }',
);
} else {
styles.remove();
}
}
eventManager.on(':preload:Decks :preload:Crafting', refresh);