Handle the case where dynamic content is in the middle of a page, selecting the first variant Patch by Seifeddine Dridi, applied with some modifications