It is important to understand the "Rules" correctly. In such a case, the ex-dividend date is the important date and it applies to both buying and selling.
Buy before the ex-dividend date and you get the extra shares. Sell before the ex-dividend date and you lose the extra shares! In total, it does not affect the company, only the buyers and sellers of the shares.