>>saeede+(OP)
The nature of programming means that there are a lot of small gaps while you work, for example as the code is compiling and deploying. These short breaks are not enough to pick up any long-term activity, so therefore the small bites of social media end up looking very appetising.
Other times you need to search for specific information. When you already have 25 tabs open, it doesn't seem that bad to open tab number 26.
The best solution that I've found was to work on cafés and libraries: places where I can easily let my eyes wander between blocks of focused work.