Extension:UserMagic

The UserMagic extension allows editors to place the name of the current user inside the content of an article, without affecting the page cache. This is done by replacing magic words inside the fully-parsed HTML after the page has been rendered and cached.

Currently defined magic words:
 * __USERNAME__ -> Name of the current user
 * __USERPAGE__ -> Link to the page of the current user
 * __USERIP__ -> IP address of the current user

Caveats
Since the magic words are not replaced until after the HTML is rendered, they cannot be used as the target of links or as template arguments. However, they can still be used as the alternate text of links, e.g. __USERNAME__

Additionally, since  tags will have already been parsed out, these magic words cannot be invalidated by. In order to explicitly print one of these words, &amp;#95; must be used in place of an underscore.

Code
This code was rewritten in 2016 and tested with MediaWiki 1.28 (although a better method would be to define a true magic word). Previous version (written in 2013 and tagged for MediaWiki 1.12+) is available in the history.