$('.buy-energy__purchase > .button--progress').mousedown();
setTimeout(function() {$('.buy-energy__purchase > .button--progress').mouseup();}, 300);
let timeout = null;
$elem.on("mousedown", function() {
doAction(...);
timeout = setTimeOut(function() {
undorAction(...);
});
});
$elem.on("mouseup", function() {
clearTimeout(timeout);
undorAction(...);
});