The more forbidden something is, the more you want it. Otherwise, it wouldn’t be forbidden. Keep that in mind when you’re trying to get rid of an undesirable behavior.
You’re not a dog. There’s no sense in treating yourself like one. So instead of trying to forbid your compulsion, study it. What do you get from it? What keeps you coming back to it?
The more you expose your forbidden fruit, the less desirable it becomes. With enough vigilance, it won’t need to be forbidden anymore.