Reload Last Carousel Image On Click

Can someone help me create a single script (vanilla or jquery) so that whenever I click on an image, the next time I refresh my browser the carousel loads that clicked image?

This is what I have so far:

When I click on an image in my carousel, this jquery script alerts me the index number of that slide:

    $('#myCarousel').on('click', '.mySlides', function () {
        alert( $(this).index('.mySlides')+1 );
    });
}); 
//Alert! 7 (ie. Current image slide is 7/10, etc)```

I have a separte vanilla javascript when I refresh my browser, the carousel loads a specific image but I have to manually insert the index number:

```window.addEventListener("load", (event) => {
  currentSlide(7); 
});```

I've reached my limit on how to make this work as a single script. Appreciate all the help :)