mirror of
https://github.com/danbulant/anti-sleep
synced 2026-07-06 19:40:33 +00:00
Initial commit
This commit is contained in:
commit
e1f1d874ef
1 changed files with 43 additions and 0 deletions
43
index.ts
Normal file
43
index.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import AutoPilot from 'https://deno.land/x/autopilot/mod.ts';
|
||||||
|
import { parse } from "https://deno.land/std/flags/mod.ts";
|
||||||
|
|
||||||
|
const args = parse(Deno.args, {
|
||||||
|
alias: {
|
||||||
|
interval: "i",
|
||||||
|
start: "s",
|
||||||
|
stop: "p"
|
||||||
|
},
|
||||||
|
default: {
|
||||||
|
interval: 300000
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const pilot = new AutoPilot();
|
||||||
|
|
||||||
|
pilot.notify("Do not sleep", "Do not sleep is now running!");
|
||||||
|
|
||||||
|
var last = {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
var lastUpdate = Date.now();
|
||||||
|
var wasActive = false;
|
||||||
|
|
||||||
|
setInterval(() =>{
|
||||||
|
if((new Date).getHours() < args.start || (new Date).getHours() > args.stop) {
|
||||||
|
if(wasActive) pilot.notify("Do not sleep", "Do not sleep is now paused");
|
||||||
|
wasActive = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wasActive = true;
|
||||||
|
var pos = pilot.mousePosition();
|
||||||
|
if(pos.x !== last.x && pos.y !== last.y) {
|
||||||
|
lastUpdate = Date.now();
|
||||||
|
} else {
|
||||||
|
if(Date.now() - lastUpdate > args.interval) { // 5minutes
|
||||||
|
pilot.moveMouse(pos.x + 1, pos.y + 1);
|
||||||
|
pilot.notify("Do not sleep", "Your mouse was moved just now.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 10000);
|
||||||
Loading…
Reference in a new issue