The way to cure this is to develop a habit that severely limits undirected online browsing and socializing. Part of it is just an education of your own aesthetic sentiments. I read James Clear's "Atomic Habits" (not that this is a special book, I was just on another kick in which I really needed to improve my productivity and picked up a suggestion to use a physical counter of some kind to make a habit stick.
I bought a bunch of marbles, and for every bloc of time that I avoid undirected browsing or social media use, I move a marble from one container to the other. My goal every day is to get through an arbitrary number of marbles (160 right now), after which I can do whatever. If I slip up and open a social media page, HN, or start browsing newspapers, I dump all the marbles out of the container, which generally makes it impossible to meet the day's goal unless the slipup is very early in the day.
This has been nothing short of amazing for my life. One issue that I had is I had a physical twitch that would start developing after a couple minutes doing one thing, like a work project, at which I would feel the urge to check the news or social media. This twinge would show up and I would type into a browser window to relieve the sensation. Instead I more or less replaced that twinge with moving the marble from one container to the other. It's made it a lot easier to focus. Over time, I stopped caring as much about the news and became more easily satisfied by very briefly reading summaries every few days.
I think a lot of web addiction is less driven by thoughts or brain issues and more by physical habits akin to nail-biting or cuticle-picking. Most of the attempts that I've made to stop addictive behavior have not worked: they were based on schedules, timers, articulated goals, and other things like that rather than recognizing the physical trigger for the habit, the result of that trigger, and just redirecting the stimulus with another physical action rather than trying to suppress it.