Is it possible to hide the number of topic views?



  • It may sound strange to hide this stat, but it is useful for my use case. I'm mainly looking to hide the following:

    alt text
    alt text

    I searched these forums and couldn't find anything related. It seems to be only doable through a plugin. I attempted using the following script in "Custom Header", but it doesn't work properly because of asynchronous stat loading:

    <script>
    $(document).ready(function(){
        $('div.stats.hidden-xs').each(function(i){
            var divObj = $(this)
            divObj.find('small').each(function(j){
                if($(this).text() == 'Views'){
                    divObj.hide()
                }
            })
        })
    })
    </script>
    

    When you first load a page, the views are shown. If you refresh it, the views get hidden the way I want.

    Thanks for your attention.


  • Global Moderator

    You can do it with CSS, too, and there's no delay.

    .category-item .stats:nth-child(5) * {
      /* to maintain formatting */
      visibility: hidden;
    
      /* to hide completely instead */
      /*display: none;*/
    }
    


  • Awesome! It worked for me and indeed, there's no delay. Also, to hide the views in the post bar, I used this one:

    .topic-main-buttons .stats:nth-child(3) * {
      /* to maintain formatting */
      visibility: hidden;
    
      /* to hide completely instead */
      /*display: none;*/
    }
    

    Thanks a lot!


Log in to reply
 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.