Extension:GlobalCssJs

This extension allows loading CSS and JavaScript (JS) from a central wiki.

The GlobalCssJs extension supports wiki farm-wide and individual site-wide "MediaWiki:Global.js"/"MediaWiki:Global.css" pages and per-user "User:$username/global.js"/"User:$username/global.css" pages on a specified central wiki. The term "global" is used to mean across a wiki farm (compare with Extension:GlobalUsage) and the capitalization ("Css" and "Js") is due to MediaWiki extension naming conventions.

If you are not using shared user tables or CentralAuth, this extension can open up a XSS vector, which allows other users to hijack the user's account, among other things. See for information on how to integrate your authentication extension with this one.

Configuration

 * Whether to enable MediaWiki:Global.js/MediaWiki:Global.css pages. By default enabled.


 * ResourceLoader configuration of the global wiki. 'wiki' should be set to the database name of the central wiki, and 'source' should be the name of the ResourceLoader source. An example configuration might look like:

Hook
If you are not using shared user tables for managing users, you can use a hook to state whether a user on one wiki is equal to another.

is the wiki the JS/CSS is being taken from, and  is the current wiki the request is being executed on. The hook will not be called if.

The function should return true if the users are the same, and false if they are not. An example subscriber can be found in the CentralAuth extension.

Usage
In the global wiki, access Special:MyPage/global.js (or Special:MyPage/global.css) and add some scripts (resp. styles) which you want to be loaded in all wikis. Be aware that, as with gadgets, variables declared with " " are not attached to the  object: they are local variables whose scope is a wrapper function inserted by ResourceLoader to implement the global module (which is called "ext.globalcssjs.user"). Therefore, if you plan to move a local script to the global module, and it needs to define global variables, make sure you use the syntax " " to declare them.