PageAutomator

I present to you PageAutomator - an automation script for the browser. It was inspired by WinAutomation. It's currently available at greasyfork, but you can use it outside the userscript, be sure to add the dependencies though. https://greasyfork.org/en/scripts/458951-pageautomator/code You can init it like this:
var automator = new PageAutomator();
var automator = new PageAutomator();
And I recommend running it after dom is fully loaded:
window.onload = function() {
var automator = new PageAutomator();

// Mouse events
automator.hover("#some-element");
automator.click("#some-element", "left");
automator.click("#some-element", "right");
automator.scroll(200);
automator.hold("#some-element", "left");
automator.hold("#some-element", "right");
automator.moveToPosition(200, 200);
automator.moveToElement("#some-element");
var position = automator.getPosition();
console.log(position);

// Keyboard events
automator.keyPress("a");
automator.keyUp("a");
automator.keyDown("a");
automator.holdKey("a");
automator.setKeyState("numlock", true);

// Block input
automator.blockInput();

// Timer events
automator.wait(1000);
automator.waitForElement("#some-element");
automator.waitForMouse("pointer");

// Conditionals
if (automator.ifElement("#some-element", "contains", "text")) {
console.log("element contains the specified text");
}

// Dialogs and message boxes
automator.showNotification("This is a notification");
automator.showDialog("This is a dialog");
automator.showCustomDialog("<p>This is a custom dialog</p>");

// Clipboard
var clipboardText = automator.getClipboardText();
console.log(clipboardText);
automator.setClipboardText("text to set to clipboard");
automator.clearClipboard();
}
window.onload = function() {
var automator = new PageAutomator();

// Mouse events
automator.hover("#some-element");
automator.click("#some-element", "left");
automator.click("#some-element", "right");
automator.scroll(200);
automator.hold("#some-element", "left");
automator.hold("#some-element", "right");
automator.moveToPosition(200, 200);
automator.moveToElement("#some-element");
var position = automator.getPosition();
console.log(position);

// Keyboard events
automator.keyPress("a");
automator.keyUp("a");
automator.keyDown("a");
automator.holdKey("a");
automator.setKeyState("numlock", true);

// Block input
automator.blockInput();

// Timer events
automator.wait(1000);
automator.waitForElement("#some-element");
automator.waitForMouse("pointer");

// Conditionals
if (automator.ifElement("#some-element", "contains", "text")) {
console.log("element contains the specified text");
}

// Dialogs and message boxes
automator.showNotification("This is a notification");
automator.showDialog("This is a dialog");
automator.showCustomDialog("<p>This is a custom dialog</p>");

// Clipboard
var clipboardText = automator.getClipboardText();
console.log(clipboardText);
automator.setClipboardText("text to set to clipboard");
automator.clearClipboard();
}
I've also tried to make the events chainable, so you can type them out like jquery events.
PageAutomator
Automate the actions on the page
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server