javascript – How to add text to URL so pages reflect only in stock options when in Magento2

Currently, on my site when I access product pages, the product counts reflect both in and out of stock options. I would like when those product pages are loaded, the url changes to add ‘?stock=1’ to the end of the url so that the counts reflect only in-stock options. The page is also being filtered using AJAX, so I need to keep the url addition throughout the filtering process by the user.