add function to analyze data as part of processing
This commit is contained in:
		
							parent
							
								
									40e4818c67
								
							
						
					
					
						commit
						8cb7537463
					
				
					 1 changed files with 25 additions and 10 deletions
				
			
		
							
								
								
									
										35
									
								
								scripts/external/processor.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								scripts/external/processor.js
									
										
									
									
										vendored
									
									
								
							|  | @ -4,18 +4,33 @@ Process the information on the website and display it on screen. | ||||||
| 
 | 
 | ||||||
| // const inject = ((await import(chrome.runtime.getURL("scripts/external/inject.js"))).default);
 | // const inject = ((await import(chrome.runtime.getURL("scripts/external/inject.js"))).default);
 | ||||||
| const scraper = (await import(chrome.runtime.getURL("scripts/external/scraper.js"))).default; | const scraper = (await import(chrome.runtime.getURL("scripts/external/scraper.js"))).default; | ||||||
|  | const product = (await import(chrome.runtime.getURL("scripts/product.js"))).default; | ||||||
| 
 | 
 | ||||||
| export default class processor { | export default class processor { | ||||||
|      #filter;  | 	#filter;  | ||||||
|  | 	 | ||||||
|  | 	async scrape (fields) { | ||||||
|  | 		this.data = new scraper ((fields) ? fields : this.targets);  | ||||||
|  | 		console.log(this.data); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	async analyze() { | ||||||
|  | 		this.product = new product(this.data); | ||||||
|  | 		await this.product.attach(); | ||||||
|  | 		console.log(this.product); | ||||||
|  | 		console.log(await this.product.analyze()); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	constructor (filter) { | ||||||
|  | 		this.#filter = filter; | ||||||
| 
 | 
 | ||||||
|      async scrape (fields) { | 		this.targets = this.#filter[`data`]; | ||||||
|           this.data = new scraper ((fields) ? fields : this.targets);  | 		this.scrape(); | ||||||
|      } |  | ||||||
|       |  | ||||||
|      constructor (filter) { |  | ||||||
|           this.#filter = filter; |  | ||||||
| 
 | 
 | ||||||
|           this.targets = this.#filter[`data`]; | 		if ((this.data) ? (((typeof (this.data)).includes(`obj`) && !Array.isArray(this.data)) ? Object.keys(this.data) : this.data) : false) { | ||||||
|           this.scrape(); | 			this.analyze(); | ||||||
|      } | 
 | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
| } | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue