Wikia Developers Wiki


847pages on
this wiki
Add New Page
Talk3 Share
High priority

Wikia has changed how user scripts work

Wikia has disabled User Scripts from running on MediaWiki and User namespace pages that end with a '.JS' file extension. This severely reduces the effectiveness of this script. It still works on CSS pages, as well as JS pages that are not MediaWiki:Common.js or User:Name/wikia.js and so on but that's it.

You can get AntiUnicruft to apply to all script pages, including the protected ones above, by installing UnsafeScripts as well.

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 Common.js, Common.css 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 this happens is that sometimes a program will add a Left-Right mark to your clipboard when you copy text and those marks are then pasted into your code. Since the code is already Left-Right, the mark is pointless and redundant; however, 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:

console.log("Confusing, huh?‎" === "Confusing, huh?");


The script has no UI or configuration, it's simply set and forget. You can add it to your Wiki's Common.js if you want to help every admin on your site avoid inadvertently breaking your scripts, or you can add it to your global.jsto have it work for you on every Wiki (or both).

importScriptPage('MediaWiki:AntiUnicruft/code.js', 'dev');

If you are putting it in Common.js, then use importArticle(s):

importArticle({type:'script', article:'w:c:dev:MediaWiki:AntiUnicruft/code.js'});

Operational Notes

The script will only run on Article pages whose names 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).

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.