Then I recall I read from somewhere that Donald Knuth prefers pen and paper to computer. I tried it and it did work for me. I just turn off the computer and use pen and paper/book/printed stuff most of the time. When I have to use the computer I leave the network cable unplugged and finish it quick; When I have to use the internet, I write down what I going to do and do it then turn off the computer; I only check HN or YouTube on meal breaks or before sleep.
I found programming with pen and paper is surprisingly effective, and arguably makes the system better designed. Reading printed code and take notes in diagrams like half a century ago make me understand better (I don't actually print everything, just collect those parts I find important to an editor then print). Turn-on computer on demand feels like going back to the lab from the dorm when the idea struck. All are slower but make steady progress, and it's enjoyable. Much better than time wasted in vain.
As in hindsight, I don't think I'm addicted because I don't have withdrawal symptoms - I don't get uncomfortable when I'm not using a computer or the Internet. It's just those websites are good at grasping my attention. If that's your case, just turn it off or lock your phone away and only get it when you need your online bank. But if you do have withdrawal symptoms, you probably need to ask professionals to address them.