# Voorkom dat de 'Last Visit'-balk kleuren verpest

**URL:** <https://meta.discourse.org/t/prevent-last-visit-bar-from-messing-up-colors/216509>\
**Category:** Product Support\
**Tags:** plugin-api\
**Created:** [30 januari 2022 om 19:49 UTC](https://meta.discourse.org/t/prevent-last-visit-bar-from-messing-up-colors/216509 "2022-01-30T19:49:58Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)\
**Post date:** [30 januari 2022 om 19:49 UTC](https://meta.discourse.org/t/prevent-last-visit-bar-from-messing-up-colors/216509/1 "2022-01-30T19:49:58Z")

</div>

We have alternating colors set up for all of our posts (and small actions) via nth-child, which looks like this:

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/6/86fc8815d9b2df92fd8c08778cd7f824e9be49bc.png)

However, the new-with-2.8 “last visit” thing counts as a small action, and so it ends up getting caught up in these alternating post colors:

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/f/3fe6274000083257fe6f9c2c09193d0f52159c52.png)

What we’d most like is to have something like the following:

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/5/15ff5bc15e1212c0010a634b2bf57da5a45a92e7.png)

Where the “last visit” bar does not end up counting as a child for the purposes of nth-child determining what color its background should be.

My first instinct was to use JavaScript to simply add a new div after any last visit bars, which does indeed work as desired:

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/c/7cd5fbf860d0dc184ffa8643655207a1c9dcaa88.png)

via

```plaintext
<script type="text/discourse-plugin" version="0.8">
    var addedElement;
    
    api.onPageChange(() =>{
        addedElement = false;
        //window.onload = lastPostFix();
    });

    async function lastPostFix()
    {
        var elements = document.getElementsByClassName('topic-post-visited');
        
        var newElement = document.createElement("div");
        newElement.classList.add('small-action');
        
        while(elements.length > 0 && !addedElement)
        {
            elements[0].parentNode.insertBefore(newElement, elements[0].nextSibling);
            addedElement = true;
        }
    }
</script>

```

However, when you scroll up or down, there are a bunch of issues this seems to cause, from posts simply refusing to load to massive blank spaces to whatever the heck is going on in the third pic:

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/f/6faf485e54b75dd6b4fa8ddfd2a8310da89db7cb.png)

* * *

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/c/5c681adcc5a7c3a550a7e56961c7328e294a2284.png)

* * *

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/e/4e7354f7c2703c1fcebf44c70b9695649da5d5f2.png)

Anybody have a better idea of how we can accomplish this?

---

_[View the full topic](https://meta.discourse.org/t/prevent-last-visit-bar-from-messing-up-colors/216509)._
