Make legend on Special:RecentChanges and Special:Watchlist collapsible

Some of the code added here is duplicated, redundant or would be
better off placed somewhere else. I know about this, but this is not
the time to fix that (and nobody would review such patches anyway…).

Change-Id: I02f2ced42f33649b6c972d35a4739372ca265e10
(cherry picked from commit a9e0c52c064f6d405b957dec99e79f86b59e0918)