Add mark page function
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| import * as URLParse from 'url-parse'; | ||||
| import { sleep } from './utils'; | ||||
| import { markPage, sleepShort } from './utils'; | ||||
| import { v4 as uuid } from 'uuid'; | ||||
| import { QueueItem } from './Queue'; | ||||
| import Scheduler from './Scheduler'; | ||||
| @@ -13,14 +13,12 @@ export default class Dashboard { | ||||
|     } | ||||
|  | ||||
|     async run() { | ||||
|         jQuery('body').append( | ||||
|             '<div style="position: absolute; top: 0; left: 0; background-color: white">Dashboard</div>' | ||||
|         ); | ||||
|  | ||||
|         const p = new URLParse(window.location.href, true); | ||||
|         console.log('PARSED LOCATION', p); | ||||
|  | ||||
|         await sleep(5000); | ||||
|         await sleepShort(); | ||||
|  | ||||
|         markPage('Dashboard'); | ||||
|  | ||||
|         if (p.pathname === '/build.php') { | ||||
|             console.log('BUILD PAGE DETECTED'); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { sleepLong } from './utils'; | ||||
| import { markPage, sleepLong, sleepShort } from './utils'; | ||||
| import { Queue, QueueItem } from './Queue'; | ||||
| import UpgradeBuildingTask from './Task/UpgradeBuildingTask'; | ||||
| import GoToBuildingAction from './Action/GoToBuildingAction'; | ||||
| @@ -17,6 +17,8 @@ export default class Scheduler { | ||||
|     } | ||||
|  | ||||
|     async run() { | ||||
|         await sleepShort(); | ||||
|         markPage('Executor'); | ||||
|         while (true) { | ||||
|             await sleepLong(); | ||||
|             const actionItem = this.popAction(); | ||||
|   | ||||
							
								
								
									
										19
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/utils.ts
									
									
									
									
									
								
							| @@ -3,8 +3,8 @@ export function sleep(ms: number) { | ||||
| } | ||||
|  | ||||
| export async function sleepShort() { | ||||
|     let ms = 2000 + Math.random() * 10000; | ||||
|     console.log('SLEEp SHORT', Math.round(ms)); | ||||
|     let ms = 2000 + Math.random() * 1000; | ||||
|     console.log('SLEEP SHORT', Math.round(ms)); | ||||
|     return await sleep(ms); | ||||
| } | ||||
|  | ||||
| @@ -13,3 +13,18 @@ export async function sleepLong() { | ||||
|     console.log('SLEEP LONG', Math.round(ms)); | ||||
|     return await sleep(ms); | ||||
| } | ||||
|  | ||||
| export function markPage(text: string) { | ||||
|     jQuery('body').append( | ||||
|         '<div style="' + | ||||
|             'position: absolute; ' + | ||||
|             'top: 0; left: 0; ' + | ||||
|             'background-color: white; ' + | ||||
|             'font-size: 24px; ' + | ||||
|             'z-index: 9999; ' + | ||||
|             'padding: 8px 6px; ' + | ||||
|             'color: black">' + | ||||
|             text + | ||||
|             '</div>' | ||||
|     ); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user