AntiUnicruft

This script cleans up a nasty set of head-scratching bugs you can get when you do a lot of copy-pasting of code into,   and other similar files. It automatically strips several magic invisible characters out of your article when you click Publish/Save.

The problem
Unicode (the way text is stored in your computer) provides several invisible 'magic' characters called 'directional marks'. These special characters are used to switch text from Left-to-Right (e.g. Latin languages) to Right-to-Left (e.g. Arabic). These markers let you mix Right-Left and Left-Right languages in a single file which can be useful when working with text... but cause serious problems when working with code (JavaScript or CSS).

If you've ever been in a situation where you're absolutely sure the code is right but it won't work so you retyped it exactly the same and it magically starts working, these evil little invisible characters were the cause. The reason is simply that sometimes you end up with Left-Right directional marks in a file (like source code) which is always Left-Right which means the mark is pointless and redundant but the script engine, being a complete pedant, will make a fuss over it and refuse to behave until those marks are removed.

Try copy and pasting the following code into your JavaScript console and run it to see the nastiness in action:

Installation
The script has no UI or configuration, it's simply set and forget. You can add it to your Wiki's  if you want to help every admin on your site avoid inadvertently breaking your scripts, or you can add it to your   to have it work for you on every Wiki (or both). If you are putting it in, then use  (s):

Operational Notes
The script will only run on Article pages that end with '.js' or '.css'. For example, it will run on 'MediaWiki:Common.js', 'User:You/global.js', 'Template:Something/appearance.css'. It will not run on anything that does not have those file extensions (this is a protection mechanism to avoid breaking articles that use directional marks intentionally).

WARNING: Currently, scripts which contain Right-Left text, like an Arabic translation for UI text, will have that text broken by this script. [This will hopefully be fixed in a future version]