call the external processor
This commit is contained in:
		
							parent
							
								
									08b10746b5
								
							
						
					
					
						commit
						e21820576e
					
				
					 1 changed files with 53 additions and 49 deletions
				
			
		|  | @ -2,60 +2,64 @@ | ||||||
| Be sensitive to changes and update the state. | Be sensitive to changes and update the state. | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| (async () => { | let main = (async () => { | ||||||
|   // Import modules.
 | 	// Import modules.
 | ||||||
|   let secretariat = await import( | 	let filters = new ((await import(chrome.runtime.getURL("scripts/filters.js"))).default); | ||||||
|     chrome.runtime.getURL("scripts/secretariat.js") | 	const processor = (await import(chrome.runtime.getURL("scripts/outside/processor.js"))).default; | ||||||
|   ); |  | ||||||
|   let filters = new ((await import(chrome.runtime.getURL("scripts/filters.js"))).default); |  | ||||||
|   // let reader = await import(chrome.runtime.getURL("scripts/reader.js"));
 |  | ||||||
| 
 | 
 | ||||||
|   class watchman { | 	class watchman { | ||||||
|     /* Check the current URL. | 		/* Check the current URL. | ||||||
| 
 | 
 | ||||||
|       @param {string} URL the page URL; default value is the current webpage | 			@param {string} URL the page URL; default value is the current webpage | ||||||
|       @return {dictionary} the filter to follow | 			@return {dictionary} the filter to follow | ||||||
|       */ | 			*/ | ||||||
|     static async observe(URL = window.location.href) { | 		static async observe(URL = window.location.href) { | ||||||
|       // Create the variable to determine the corresponding key.
 | 			// Create the variable to determine the corresponding key.
 | ||||||
|       let activity = false; | 			let activity = await filters.select(URL); | ||||||
|        |  | ||||||
|       activity = await filters.select(URL); |  | ||||||
| 
 | 
 | ||||||
|       return activity; | 			return activity; | ||||||
|     } | 		} | ||||||
| 
 | 
 | ||||||
|     /* Act on the page. | 		/* Act on the page. | ||||||
| 
 | 
 | ||||||
|         @param {dictionary} filters the filter to work with | 		@param {dictionary} filters the filter to work with | ||||||
|         @return {boolean} the state | 		@return {boolean} the state | ||||||
|         */ | 		*/ | ||||||
|     static act(filters) { | 		static act(matches) { | ||||||
|       console.log( | 			console.log("ShopAI works here! Click on the button in the toolbar or website to start."); | ||||||
|         "ShopAI works here! Click on the button in the toolbar or website to start.", | 			// Show loading screen while the load is incomplete. 
 | ||||||
|       ); | 			 | ||||||
|       secretariat.write("state", true); | 			// Set the icon to indicate that it's active.
 | ||||||
|       // TODO
 |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     /* Set the program to standby utnil next load. | 			// Begin. 
 | ||||||
|      */ | 			let PROC = new processor(matches); | ||||||
|     static standby() { |  | ||||||
|       // Set the icon to indicate that it's not active. 
 |  | ||||||
|       secretariat.write("state", false); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     static async job() { | 			window.addEventListener(`load`, (event) => { | ||||||
|       /* The main action. */ | 				// Remove the loading screen. 
 | ||||||
|       (watchman.observe()).then((job_task) => { | 			}); | ||||||
|         if (job_task && Object.keys(job_task).length !== 0) { | 		} | ||||||
|           watchman.act(job_task); |  | ||||||
|         } else { |  | ||||||
|           watchman.standby(); |  | ||||||
|         } |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   watchman.job(); | 		/* Set the program to standby utnil next load. | ||||||
| })(); | 		 */ | ||||||
|  | 		static standby() { | ||||||
|  | 			// Set the icon to indicate that it's not active. 
 | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		static async job() { | ||||||
|  | 			/* The main action. */ | ||||||
|  | 			 | ||||||
|  | 			(watchman.observe()).then((RULES) => { | ||||||
|  | 				if (RULES && Object.keys(RULES).length !== 0) { | ||||||
|  | 					watchman.act(RULES); | ||||||
|  | 				} else { | ||||||
|  | 					watchman.standby(); | ||||||
|  | 				} | ||||||
|  | 			}); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	watchman.job(); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | main(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue