Pi-hole cannot block YouTube ads and doesn't interact with any site traffic at all. For this you will probably need some sort of browser extension/add-on. If your browser supports changing User Agent on a per-site basis you may be able to make it load the mobile version instead of the desktop version.
first of all, thanks for your really quick comment.
i'm in the browser with this code; I can also add chrome with the (ctrl shift j) keys, and YouTube switches to the mobile version and I don't see any ads. my goal is to add the code to pihole and I want it to open automatically when I enter YouTube from the browser on my linux tv.
Pi-hole is just blocking or resolving domain names. It cannot affect how applications interact with the addresses that it resolves. It is not involved in that part at all.
No. Pi-hole is a domain blocker. All it sees is queries for domains. It has no visibility into cookies, paths on a URL, javascript elements that are loaded, etc.
Pi-hole is not a web browser, so you can't add this code to Pi-hole and have it change the behavior of your Linux TV browser.