src/javascript/enhancements/cssEnhancements.ts   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 7

Size

Lines of Code 60
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 45
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 7
mnd 6
bc 6
fnc 1
bpm 6
cpm 7
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B cssEnhancements.ts ➔ init 0 55 7
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
}