Assign Badges sending a notification on every page visit; help!

Makes perfect sense.

Could you help me the code for checking the current badges first? I thought of that sort of thing, but I haven’t found that anywhere in the API reference.