Injecting custom code after sorting collection

Hi all –

I have 8 elements on a collection template page for a collection with 8 items. I want one of the eight elements to be conditionally visible depending on which of the 8 item pages the user is on. Everything I’ve tried with Webflow’s built-in condtional visibility doesn’t work for this use case. I wrote a script (with the help of ChatGPT :slight_smile: and actually was able to achieve mostly what I wanted by targeting a search of the URL … BUT, for a brief second when I sort the product collection it shows all 8 elements on the page, as opposed to just the one that corresponds to it. I was able to mostly successfully work with ChatGPT to get the infinite scroll to work with the code, so it’s just the sorting now that’s the issue. Any thoughts from humans?

Live page (Myrcene Terpenes | Order at Our Online Dispensary) and read-only shared below:


Here is my site Read-Only: [LINK](Webflow - Copy of TJ - The Revolution)
(how to share your site Read-Only link)