1
|
|
|
import { getGlobalConfiguration, SETTINGS_websiteHideUnusedTabs, SETTINGS_websiteOptimizeListAppearance } from '../configuration/configuration'; |
2
|
|
|
import * as core from '../utils/aniwatchCore'; |
3
|
|
|
|
4
|
|
|
export function init(): void { |
5
|
|
|
getGlobalConfiguration().getProperty(SETTINGS_websiteHideUnusedTabs, value => { |
6
|
|
|
// if disabled, add class to avoid our css optimizations |
7
|
|
|
if (!value) { |
8
|
|
|
let disableFunc = (node: Element) => { |
9
|
|
|
let disableNode = (node: Element) => { |
10
|
|
|
node.classList.add('awp-hide-unused-disabled') |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
if (node.tagName === 'MD-TAB-ITEM') { |
14
|
|
|
disableNode(node); |
15
|
|
|
} |
16
|
|
|
else { |
17
|
|
|
node.querySelectorAll('md-tab-item').forEach(node => disableNode(node)); |
18
|
|
|
} |
19
|
|
|
}; |
20
|
|
|
|
21
|
|
|
core.registerScript((node: Node) => { |
22
|
|
|
if (node instanceof Element) { |
23
|
|
|
disableFunc(node); |
24
|
|
|
} |
25
|
|
|
}, ".*"); |
26
|
|
|
|
27
|
|
|
core.runAfterLoad(() => { |
28
|
|
|
disableFunc(document.body); |
29
|
|
|
}, ".*"); |
30
|
|
|
} |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
getGlobalConfiguration().getProperty(SETTINGS_websiteOptimizeListAppearance, value => { |
34
|
|
|
// if disabled, add class to avoid our css optimizations |
35
|
|
|
if (!value) { |
36
|
|
|
let disableFunc = (node: Element) => { |
37
|
|
|
let disableNode = (node: Element) => { |
38
|
|
|
node.classList.add('awp-list-disabled') |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if (node.tagName === 'MD-LIST-ITEM') { |
42
|
|
|
disableNode(node); |
43
|
|
|
} |
44
|
|
|
else { |
45
|
|
|
node.querySelectorAll('md-list-item').forEach(node => disableNode(node)); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
core.registerScript(node => { |
50
|
|
|
if (node instanceof Element) { |
51
|
|
|
disableFunc(node); |
52
|
|
|
} |
53
|
|
|
}, ".*"); |
54
|
|
|
|
55
|
|
|
core.runAfterLoad(() => { |
56
|
|
|
disableFunc(document.body); |
57
|
|
|
}, ".*"); |
58
|
|
|
} |
59
|
|
|
}); |
60
|
|
|
} |