I found this one is clean and simple.
Array.from(document.querySelectorAll("ali#credit")).forEach(button=>button.click())
from this site: https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/#comment-1602558
edit 1
Thanks to Sliavik in comment.
document.querySelectorAll("ali#credit").forEach(el=>el.click())
is safe to call