"When you fight something, you're tied to it forever. As long as you're fighting it, you’re giving it power."
When I learned to stop feeling bad/guilty/thinking this was a problem to solve and just let my mind drift, I found that my mind naturally learned when it was disciplined work time vs. browse the internet time. Personally, I noticed that when I didn't have any artificial restriction, I was less inclined to waste time on those things.
In practice: "oh, my mind doesn't want to do that other thing right now but it does want to go look at this thing; let it." The more I've loosened my grip, the less distractions have affected my productivity.