Trend Micro Vision One Search Auto-Clicker Auto-Refresher
Use case
I need to auto-refresh the Trend Vision One Quarantine list every minute since they haven't added that into their platform. I tried using an auto-clicker / auto-refresh browser extension, but it would only hard refresh the page or click on anchor links via XPath, not buttons.
I eventually realized I could just write some JavaScript that would do the same thing. Below is the result. I found the buttonXpath is different depending on your browser, so if you use this in anything other than Chrome, you'll probably need to update that variable before using.
Code
# start the clicking
function clickButtonByXpath(xpathExpression) {
try {
const result = document.evaluate(xpathExpression, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
const element = result.singleNodeValue;
if (element) {
element.click();
console.log(`Button found and clicked: ${xpathExpression}`);
} else {
console.warn(`Button not found for XPath: ${xpathExpression}`);
}
} catch (error) {
console.error(`Error clicking button via XPath: ${error}`);
}
}
// Define the XPath expression for your button
const buttonXpath = '//*[@id="root"]/div[2]/div/div/main/div/div/div[2]/div/div[3]/div[2]/button'; // Replace with your actual XPath
// Set an interval to call the function every 60 seconds (60000 milliseconds)
const buttonClickInterval = setInterval(() => {
clickButtonByXpath(buttonXpath);
}, 60000);
# stop the button clicking
clearInterval(buttonClickInterval);
-end