I can totally relate to this concern. As a full-time employee and a part-time graduate student, I am often bombarded with tasks that I needed to comply with, which usually come with strict deadlines. There are times when I end up cramming not because they didn't give sufficient time but because I wasn't able to manage my time wisely. I am guilty with what you said, as I often get distracted by social media and mindless internet browsing to the point where I fall asleep while holding my phone. This routine lasted for a long time before I decided to do something about it.
To regain my old productive self, I deactivated my social media accounts and engaged in new activities that would not require me going online such as reading books and sketching. I told myself that I should let go of this bad habit if I want to achieve my goals. This totally worked for me, as I was able to finish my tasks ahead of time. And although I wasn't on tight schedule anymore, I still did not activate my accounts until I get used to my new routine.
Right now, I am slowly going back to the online world but not as active as before. So I guess it depends on how loyal you are to your own cause. I also think that one should not only realize if something's wrong but to actually do something about it. Sometimes when we can't achieve something, it's not only because of the outside reasons, but because we haven't done what is required to achieve the goal. The temptations of this modern world are really tempting but let us do our best to not give in.