I want to trigger a script when a lightbox starts

Im using fin sweet CMS slider to populate a slider. each slide has a lightbox trigger, plus I have one other trigger on the page.

because fin sweet uses a hidden div that has the lightbox triggers, I’m getting double ups when the lightbox opens.

I either need to fix that part, or just remove the duplicate thumbnails when the lightbox opens. using a click event on the lightbox trigger doesn’t seem to work.

Here is my current code

function removeDuplicates() {
const st = new Set();
for (const div of document.querySelectorAll(‘.w-lightbox-item’)) {
if (st.has(div.textContent.trim())) {
div.parentNode.removeChild(div);
}
st.add(div.textContent.trim());
}
}

$(‘.lightboxtrigger’).click(removeDuplicates());
$(‘.w-lightbox’).click(removeDuplicates());

Here is the page:
https://key2-co-nz.webflow.io/developments/mcleod-green

Any ideas appreciated.

Ta