Enhance Automation Anywhere with a Command Palette
当前为
// ==UserScript==
// @name Command Palette AutomationAnywhere
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Enhance Automation Anywhere with a Command Palette
// @author jamir-boop
// @match *://*.my.automationanywhere.digital/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=automationanywhere.digital
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const commands = {
a: addAction,
adv: addVariable,
v: showVariables,
duv: deleteUnusedVariables
};
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.code === 'KeyP') {
const userInput = prompt("Enter a command (a, adv, v, duv) or 'help' for a list of commands:", "");
const command = commands[userInput];
if (command) {
command();
} else {
showHelp();
}
e.preventDefault(); // This will prevent the default action for the Ctrl+P key combination
}
});
function addAction() {
const addButton = document.querySelector("div.jsx-1665687331:nth-child(2) > div:nth-child(1) > header:nth-child(1) > div:nth-child(1) > button:nth-child(1)");
addButton.click();
const cancelButton = document.querySelector('div.editor-palette-search__cancel button');
cancelButton.click();
}
function addVariable() {
try {
const accordion = document.querySelector("div.editor-palette__accordion:nth-child(1)");
const addButton = accordion.querySelector("header:nth-child(1) button:nth-child(1)");
addButton.click();
} catch (error) {}
try {
const cancelButton = document.querySelector('div.editor-palette-search__cancel button');
cancelButton.click();
} catch (error) {}
try {
const createButton = document.querySelector('button[name="create"]');
createButton.click();
} catch (error) {}
try {
const confirmButton = document.querySelector("div.action-bar--theme_default:nth-child(1) > button:nth-child(2)");
confirmButton.click();
} catch (error) {}
}
function showVariables() {
const accordion = document.querySelector("div.editor-palette__accordion:nth-child(1)");
const addButton = accordion.querySelector("header:nth-child(1) button:nth-child(1)");
addButton.click();
const variablesButton = document.querySelector(".rio-focus--border-radius_pill");
variablesButton.click();
}
function deleteUnusedVariables() {
const accordion = document.querySelector("div.editor-palette__accordion:nth-child(1)");
const addButton = accordion.querySelector("header:nth-child(1) button:nth-child(1)");
addButton.click();
const menuButton = document.querySelector("button.action-bar__item--is_menu:nth-child(5)");
menuButton.click();
const deleteButton = document.querySelector("button.rio-focus--inset_4px:nth-child(2)");
deleteButton.click();
}
function showHelp() {
alert("List of commands:\n" +
"a: Add Action\n" +
"adv: Add Variable\n" +
"v: Show Variables\n" +
"duv: Delete Unused Variables");
}
})();