You can use the setInterval() to trigger it every second.
In order to stop the click after ntimes you can add a data field to your button.
The snippet:
function doit() {
$("#bin").append("hi" + "<br>")
}
setInterval(() => {
var max = +$("#btn").data('max') - 1;
if (max >= 0) {
$("#btn").data('max', max);
$("#btn").trigger('click');
} else {
clearInterval(timer);
}
}, 1000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="btn" data-max="10" onclick="doit()">|||</button>
<div id="bin">
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…