Skip to content

Instantly share code, notes, and snippets.

@PonteIneptique
Created December 16, 2022 13:58
Show Gist options
  • Save PonteIneptique/a53e5a402c85a79d82b6e920532ff190 to your computer and use it in GitHub Desktop.
Save PonteIneptique/a53e5a402c85a79d82b6e920532ff190 to your computer and use it in GitHub Desktop.
Macro eScriptorium
function link() {
document.dispatchEvent(new KeyboardEvent("keydown", {
'key': 'a', "charCode": 0, "keyCode": 65, "ctrlKey": true
}));
setTimeout(() => {
document.dispatchEvent(new KeyboardEvent("keydown", {
'key': 'y', "charCode": 0, "keyCode": 89
}));
}, 500);
}
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
function doTheThing() {
link();
setTimeout(function () {
nextBtn = document.querySelector("#next-part");
if (nextBtn) {
document.dispatchEvent(new KeyboardEvent("keydown", {
"keyCode": 34 // PageDown
}));
console.log("Dispatched");
setTimeout(doTheThing, 3000);
} else {
alert("Finished !");
}
}, 2000);
}
doTheThing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment