I study computer science and any time I sit down to code, I just browse or watch Youtube. Anything but do the work. Days and even months have gone by like this where I haven't done even an hour of learning. Its tough because in order to code I need to be in front of a screen but my brain refuses to study and just looks for that dopamine hit. My grades have suffered and I feel like a constant failure.
To clarify this is not an effect of the pandemic but has been happening for the past few years.
Habits are real and very powerful. One thing that worked for me in Uni, (besides a fine-tuned regimen of stimulants and whisky,) was to have a particular table where I did my schoolwork and writing and where I didn't ever just hang out online. If you work from a desktop so can't separate your leisure space from your work space, you might try some other trigger or talisman that you learn to associate with work time as opposed to leisure. This could take the form of an object, a routine, or even a thinking cap. The trick is to remove the trigger to fuck around online that you get from sitting down where you always fuck around online.
When I light a candle at my desk it's Work time
I've tried doing this and it goes well for a week or two. Then I falter and I go into a downward spiral where its a complete relapse to my old habits. :/
Just gotta break through that barrier and keep at it until force of habit takes over. I wish there were an easy switch, but some things do take a little pushthrough.
That's normal for trying to create new habits. Just keep trying, remind yourself that it works when you do it (the opposite of the little voice inside your head that tells you that you suck when you mess up), and when you (inevitably) mess up, forgive yourself and get back on track.
Was about to give this same advice. You can also change your clothes. "Work/school clothes" = time to work, ratty pjs = time to play.