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())) {


Here is the page:

Any ideas appreciated.