Image Hiding menus and logic
[4Free-FSE.git] / src / main.ts
blobeb2592851d66300557c7b39f2dcbfd26c5934f19
1 class Main extends FeatureInterface{
2         features:any = {};/*;any bypasses dot notation issues on objects*/
3         settings:any = {};
4         
5         constructor(){
6                 super();
7                 if(!storageAvailable('localStorage')) {alert("4F-FSE: local storage error"); return;}
8                 else this.activate();   
9                 this.retrieveStates();
10                 this.init();
11                 this.decideAction();
12                 this.observeEvents();
13         }
14         
16         retrieveStates(){
17                 var top_bar = new TopBar();     
18                 top_bar.build();
19                 this.settings = top_bar.getSettingsArr();
20         }
21         
22         init():void{    
23                 if(true){
24                         this.features.image_hider = new ImageHider();
25                 }
26                 if(true){
27                         this.features.image_replacer = new TextReplacer();
28                 }
29                 if(this.settings.password_settings == 'true'){
30                         this.features.text_replacer = new PasswordViewer();
31                 }
32         }
33         
34         activate(){ console.log("4F-FSE Starting");     }
35         storeStates(){}
36         
37         observeEvents():void{
38                 document.addEventListener('PostsInserted', evt => this.decideAction());
39         }
40         decideAction():void{
41                 var start:any = document.getElementById('delform');
42                 var itterator:any = document.createNodeIterator(start, NodeFilter.SHOW_ELEMENT);
43                 var node:any;
45                 for(let feature_key in this.features)
46                         this.features[feature_key].retrieveStates();
47                 
48                 while((node = itterator.nextNode())){
49                         for(let feature_key in this.features)
50                                 this.features[feature_key].decideAction(node);
51                 }
52         }
55 document.addEventListener('4chanXInitFinished', function(){new Main();});