My strategy is having a dedicated hard-drive with a custom OS that I boot into, and this allows me to stay in a specific context (e.g coding) for a number of hours.
Then when I feel like being distracted and doing some mindless scrolling, I boot into another OS that's tailor made for that. Then it's hard to confuse contexts, and you don't mindlessly switch into distraction mode. Sometimes friction is good.