What do you mean by loophole? Loophole in what?
This may have been a viable strategy long time ago, but as with all loopholes, when they become popular, they stop working.
As it stands, whenever you buy a stock just before the ex-div date, it will drop by the dividend amount immediately after. If you happened to have experienced stock price going up after the ex-dividend date, it is likely that it went down (just as it has to) but then simply went up due to other factors, such as positive news sentiment, beneficial announcements or simply shares’ demand being above the supply/demand equilibrium which naturally drives prices upwards