You don't. There are some great suggestions in this thread. I would definitely recommend reducing social media usage, random browsing, picking up meditation, sleeping, and looking to learn new skills. None of those will overcome or avoid the need for instant gratification because seeking dopamine rushes is something we do no matter what. You need to change what gives you the rush. Define the end goal, break up the project into chunks, and then award yourself when you complete a chunk. This is how video games work, they divide up long-range goals into chunks, and then award you for those chunks. I'm currently training for my second-degree black belt. I have no idea when I will get it, so instead, I focus on daily practice which gives me the hit, which then combines with the long range pleasure of knowing that so long as I continue to practice and improve, I will get promoted.
Before you ask yourself how can I avoid something, it's better to ask yourself how you can use it to improve yourself. Fighting against something drains your willpower and you only have a limited amount.
Before you ask yourself how can I avoid something, it's better to ask yourself how you can use it to improve yourself. Fighting against something drains your willpower and you only have a limited amount.