You can use xdotool to continuously click where the link would be until the program notices the window title changes. When the window title changes, that means the link has been clicked, and the new page is loading.
Clicking function:
ff_window=$(xdotool search --all --onlyvisible --pid "$(pgrep firefox)" --name ".+")
click-at-coords() {
title_before=$(xdotool getwindowname $ff_window)
while true; do
sleep 1
title_now=$(xdotool getwindowname $ff_window)
if [[ $title_now != $title_before]]; then
break
else
xdotool windowfocus --sync "$ff_window" mousemove --sync "$1" "$2" click 1
fi
done
}
Assuming that you're using xdotool to click using coordinates:
# replace each x and y with the coordinates of each link
# example with 2 sets of coordinates: all_coords=("67 129" "811 364")
all_coords=("x y" "x y")
for sub in "${all_coords[@]}"; do
coords=($sub)
click-at-coords "${coords[@]}"
done