Loop through each provided entry
This commit is contained in:
		
							parent
							
								
									aca048f3d6
								
							
						
					
					
						commit
						c6f1249c44
					
				
					 1 changed files with 23 additions and 16 deletions
				
			
		|  | @ -48,12 +48,16 @@ export default class BackgroundImporter { | ||||||
| 					delete configuration[`OOBE`]; | 					delete configuration[`OOBE`]; | ||||||
| 				 | 				 | ||||||
| 					// Replace local URLs of filters to corresponding chrome extension pages.
 | 					// Replace local URLs of filters to corresponding chrome extension pages.
 | ||||||
|  | 					const checkURL = async () => { | ||||||
| 						if (((typeof configuration[`settings`][`filters`]).includes(`obj`) && configuration[`settings`][`filters`]) ? Object.keys(configuration[`settings`][`filters`]).length : false) { | 						if (((typeof configuration[`settings`][`filters`]).includes(`obj`) && configuration[`settings`][`filters`]) ? Object.keys(configuration[`settings`][`filters`]).length : false) { | ||||||
| 						for (let FILTER_NUMBER = 0; FILTER_NUMBER < Object.keys(configuration[`settings`][`filters`]).length; FILTER_NUMBER++) { | 							let FILTERS = {}; | ||||||
| 							let SOURCE = (Object.keys(configuration[`settings`][`filters`]))[FILTER_NUMBER]; | 							FILTERS[`current`] = configuration[`settings`][`filters`]; | ||||||
|  | 							FILTERS[`updated`] = {}; | ||||||
|  | 							 | ||||||
|  | 							for (let FILTER_NUMBER = 0; FILTER_NUMBER < Object.keys(FILTERS[`current`]).length; FILTER_NUMBER++) { | ||||||
|  | 								let SOURCE = Object.keys(FILTERS[`current`])[FILTER_NUMBER]; | ||||||
| 								 | 								 | ||||||
| 								// Check if the URL is invalid. 
 | 								// Check if the URL is invalid. 
 | ||||||
| 							 |  | ||||||
| 								if (!(URLs.test(SOURCE))) { | 								if (!(URLs.test(SOURCE))) { | ||||||
| 									// Set the URL. 
 | 									// Set the URL. 
 | ||||||
| 									let ORIGIN = {"raw": SOURCE}; | 									let ORIGIN = {"raw": SOURCE}; | ||||||
|  | @ -63,14 +67,17 @@ export default class BackgroundImporter { | ||||||
| 								 | 								 | ||||||
| 									// Attempt to verify the existence of the file. 
 | 									// Attempt to verify the existence of the file. 
 | ||||||
| 									if (await net.download(ORIGIN[`local`], `json`, true)) { | 									if (await net.download(ORIGIN[`local`], `json`, true)) { | ||||||
| 									configuration[`settings`][`filters`][ORIGIN[`local`]] = configuration[`settings`][`filters`][ORIGIN[`raw`]]; | 										FILTERS[`updated`][ORIGIN[`local`]] = FILTERS[`current`][ORIGIN[`raw`]]; | ||||||
| 									};	 | 									};	 | ||||||
| 								 | 								} else { | ||||||
| 								// Delete the illegal URLs. 
 | 									FILTERS[`updated`][SOURCE] = FILTERS[`current`][SOURCE]; | ||||||
| 								delete configuration[`settings`][`filters`][ORIGIN[`raw`]]; |  | ||||||
| 								}; | 								}; | ||||||
| 							}; | 							}; | ||||||
|  | 							configuration[`settings`][`filters`] = FILTERS[`updated`]; | ||||||
|  | 							return(FILTERS[`updated`]); | ||||||
| 						}; | 						}; | ||||||
|  | 					}; | ||||||
|  | 					await checkURL(); | ||||||
| 					 | 					 | ||||||
| 					// Set the template. 
 | 					// Set the template. 
 | ||||||
| 					template.set(configuration); | 					template.set(configuration); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue