Scrape data when opened and results don't exist
This commit is contained in:
		
							parent
							
								
									3cd5fb2172
								
							
						
					
					
						commit
						a1d5f1f315
					
				
					 1 changed files with 21 additions and 12 deletions
				
			
		|  | @ -42,12 +42,17 @@ class Page_Popup extends Page { | |||
| 		} | ||||
| 
 | ||||
| 		// Update all other data. 
 | ||||
| 		this[`status`] = (DATA[`status`]) | ||||
| 		this[`status`] = (DATA[`status`] != null) | ||||
| 			? DATA[`status`] | ||||
| 			// Accomodate data erasure. 
 | ||||
| 			: ((this[`status`]) | ||||
| 				? this[`status`] | ||||
| 				: {}); | ||||
| 
 | ||||
| 		// Call for scraping of data if global data does not indicate automatic scraping or if data doesn't exist. 
 | ||||
| 		if (!await global.read([`settings`, `behavior`, `autoRun`]) && DATA[`status`] == null) { | ||||
| 			this.send(); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	async loading() { | ||||
|  | @ -72,7 +77,7 @@ class Page_Popup extends Page { | |||
| 			}); | ||||
| 			 | ||||
| 			let PAGE = PAGES[((this[`status`][`done`]) | ||||
| 				? ((this[`status`][`error`]) | ||||
| 				? ((this[`status`][`error`] && this[`status`][`error`] != {}) | ||||
| 					? `error` | ||||
| 					: `results`) | ||||
| 				: `loading`)]; | ||||
|  | @ -104,14 +109,7 @@ class Page_Popup extends Page { | |||
| 		} | ||||
| 	}; | ||||
| 	 | ||||
| 	events() { | ||||
| 		(document.querySelector(`[data-action="open,settings"]`)) ? document.querySelector(`[data-action="open,settings"]`).addEventListener("click", () => { | ||||
| 			chrome.runtime.openOptionsPage(); | ||||
| 		}) : false; | ||||
| 		(document.querySelector(`[data-action="open,help"]`)) ? document.querySelector(`[data-action="open,help"]`).addEventListener("click", () => { | ||||
| 			new Window(`help.htm`); | ||||
| 		}) : false; | ||||
| 		(document.querySelector(`[data-action="analysis,reload"]`)) ? document.querySelector(`[data-action="analysis,reload"]`).addEventListener("click", () => { | ||||
| 	send() { | ||||
| 		try { | ||||
| 			// Send a message to the content script. 
 | ||||
| 			Tabs.query(null, 0).then((TAB) => { | ||||
|  | @ -121,6 +119,17 @@ class Page_Popup extends Page { | |||
| 			logging.error(err.name, err.message, err.stack); | ||||
| 			throw (err); | ||||
| 		}; | ||||
| 	} | ||||
| 
 | ||||
| 	events() { | ||||
| 		(document.querySelector(`[data-action="open,settings"]`)) ? document.querySelector(`[data-action="open,settings"]`).addEventListener("click", () => { | ||||
| 			chrome.runtime.openOptionsPage(); | ||||
| 		}) : false; | ||||
| 		(document.querySelector(`[data-action="open,help"]`)) ? document.querySelector(`[data-action="open,help"]`).addEventListener("click", () => { | ||||
| 			new Window(`help.htm`); | ||||
| 		}) : false; | ||||
| 		(document.querySelector(`[data-action="analysis,reload"]`)) ? document.querySelector(`[data-action="analysis,reload"]`).addEventListener("click", () => { | ||||
| 			this.send(); | ||||
| 		}) : false; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue