Personally, acting against my "better judgment" almost always results from a failure of emotional regulation. The only way I've found to reliably solve this problem has been to develop awareness of the emotional issues underlying ill-considered reactions, and develop the capacity to peacefully experience those emotions without a behavioral reaction. Technical solutions like leechblock and organizational solutions like strict scheduling can temporarily mask the problem, but they don't last, because I experience them as a form of fighting with myself, and when I fight with myself, I always lose.