Add mark page function
This commit is contained in:
parent
ce4695251f
commit
3b7b86fa11
@ -1,5 +1,5 @@
|
|||||||
import * as URLParse from 'url-parse';
|
import * as URLParse from 'url-parse';
|
||||||
import { sleep } from './utils';
|
import { markPage, sleepShort } from './utils';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { QueueItem } from './Queue';
|
import { QueueItem } from './Queue';
|
||||||
import Scheduler from './Scheduler';
|
import Scheduler from './Scheduler';
|
||||||
@ -13,14 +13,12 @@ export default class Dashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run() {
|
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);
|
const p = new URLParse(window.location.href, true);
|
||||||
console.log('PARSED LOCATION', p);
|
console.log('PARSED LOCATION', p);
|
||||||
|
|
||||||
await sleep(5000);
|
await sleepShort();
|
||||||
|
|
||||||
|
markPage('Dashboard');
|
||||||
|
|
||||||
if (p.pathname === '/build.php') {
|
if (p.pathname === '/build.php') {
|
||||||
console.log('BUILD PAGE DETECTED');
|
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 { Queue, QueueItem } from './Queue';
|
||||||
import UpgradeBuildingTask from './Task/UpgradeBuildingTask';
|
import UpgradeBuildingTask from './Task/UpgradeBuildingTask';
|
||||||
import GoToBuildingAction from './Action/GoToBuildingAction';
|
import GoToBuildingAction from './Action/GoToBuildingAction';
|
||||||
@ -17,6 +17,8 @@ export default class Scheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
|
await sleepShort();
|
||||||
|
markPage('Executor');
|
||||||
while (true) {
|
while (true) {
|
||||||
await sleepLong();
|
await sleepLong();
|
||||||
const actionItem = this.popAction();
|
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() {
|
export async function sleepShort() {
|
||||||
let ms = 2000 + Math.random() * 10000;
|
let ms = 2000 + Math.random() * 1000;
|
||||||
console.log('SLEEp SHORT', Math.round(ms));
|
console.log('SLEEP SHORT', Math.round(ms));
|
||||||
return await sleep(ms);
|
return await sleep(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,3 +13,18 @@ export async function sleepLong() {
|
|||||||
console.log('SLEEP LONG', Math.round(ms));
|
console.log('SLEEP LONG', Math.round(ms));
|
||||||
return await sleep(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>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user