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