I have to disagree with using WD40 on/near chains or any where on a bicycle, bearings or any where you need a lubricant to stay. It washes the grease away.
WD40+bicycles - Google Search
For chains, I use bacon grease. (I really do) It is not near as good as the fancy stuff and slings off pretty fast. But is free and really soaks in. But the specifically made for MC chains is amazing.