Can anyone please convert this jQuery snippet into vanilla JavaScript. I am not familiar with jQuery. I would be very thankful

Same as title. Code at this gist. You can remove the extra blank lines.

Thanks in advance!

Edit: I tried it myself and made this. But it isn’t working.