.spacer {
    display: block;
    height: 1300px;
  }
</style>
<div class="container">
  <div class="box"></div>
  <span class="spacer"></span>
</div>
<script>
  const scroller = document.querySelector('.container');
  const thumb = document.querySelector('.box');
  const scrollerHeight = scroller.getBoundingClientRect().height;
  const thumbHeight = scrollerHeight * scrollerHeight / scroller.scrollHeight;
  const factor = (scrollerHeight - thumbHeight)/(scroller.scrollHeight - scrollerHeight);
  thumb.styl