It seems to me that badges like “fanatic” can be automated, i.e. someone could put a script together to “earn” that badge. Is there any safeguard against such practice? Or is it regarded as fair-play (as in “if you even managed to put such a script together, dude, you deserve it”?!
Most bot automation is successfully thwarted by Captcha's.
In the case of Fanatic, if someone really wants to go to all the trouble to write a script, and then wait the 100 days it takes for that script to hit the site once each day to obtain the badge, I'd say they deserve it.
I think you're asking the wrong question here. While cheating to obtain badges may violate the spirit of gathering them, no one really cares what you do to get a badge. It's just a badge after all. Badges don't give you reputation, and they don't gain you additional privileges throughout the site.
However, certain badges which involve behavior which may be considered destructive to the site and other users is a problem. Automating votes or reviews, for instance, is a very destructive behavior that can cause the quality of the site to decrease. Actions such as these will result in a lengthy suspension.
Writing a script to get yourself the Fanatic badge - whatever, go for it, we really couldn't care less.
Writing a script to get the Publicist badge - you're starting to push the line. While not causing too much harm, you would be making a question appear more popular and accessible to other visitors than it actually is in reality.
Writing a script to reach your 300 votes for Civic Duty - we have a problem here. While you're free to vote how you please, an automated process certainly isn't voting based on the content. That would be similar to voting based on a user, which is definitely discouraged.
Writing a script to automatically edit posts to get to Copy Editor - you can probably expect a suspension shortly after.
So any consequences you encounter would be a result of the actions you are taking in order to gain a badge and how harmful they are to our site as a whole. Visiting the site is completely harmless, so why would we have a problem with that, even if it does give you a badge?
Yes it can technically be automated.
But only the SO devs know the Exact way to get the badge (actions taken etc)
So your script could be useless and a waste of time :-P