catalog – How do I get all products that are displayed on a page?

I am trying to get all the products which are displayed on the current page. The information is used for tracking cookies on the page.ready call.

It was possible to get the product from the product page using the Registry class, on the cart and checkout pages I can use the Cart class. How can I get the currently displayed products on the catalog page?

Both classes are deprecated as I am on magento 2.4.3 .