For you I would recommend the book: The Willpower Instinct by Kelly McGonigal. (audiobook is also well narrated)
It's well written and full of great methods for gaining your self control back.
Now what I have practised is being mindful of my actions, and treat the time when I work, study as time without youtube videos, without writing long HN posts and so on.
It's a lot harder than having some app to ping you to stop browsing. But I think it's what works better in the long run. You choose the time when you work, say a couple of hours, then take a break. No mindless browsing in between. Or well actually what has worked best for me is to have no mindless browsing at all during the best part of the day, since the feedback loop is too strong when you get accustomed to looking "just one more video".
But I'm curious to try this out. We'll see. But I'm sceptical.
On my iphone I have found myself mindlessly clicking the "add 15 minutes" of screen time and typing in my 4 digit code so often that it is now just muscle memory to do so. Yes, I have no self control.
Could you add a feature so you have to type in a pin to continue BUT the number pad is in a random order, to break up muscle memory? Or randomly re-arrange the add 1,5,15 min buttons? Or a math problem?