Wikipedia:WikiProject User scripts/Scripts/Inclusion

From Wikipedia, the free encyclopedia

Use these commands to include things from other places:

[edit] Javascript

importScript(); is now built into the site

/* Include a script from another location */

function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<scr' + 'ipt type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript"></scr' 
             + 'ipt>'); /* (Broken up so that page preview doesn't get confused) */

then include a script like so:

winc('[[User:SOMEONE/monobook.js]]');         /* Comment about what the script does */

See User:Quarl/monobook.js

[edit] Synchronize across wikis

A more concise version for including your user js to synchronize across wikis:

document.write('<scr' + 'ipt type="text/javascript" src="http://en.wikipedia.org/w/index.php?title='
             + 'User:YOURUSERNAME/monobook.js'  /* <-- Replace this with your monobook.js location */
             + '&action=raw&ctype=text/javascript"></scr'
             + 'ipt>'); /* (Broken up so that page preview doesn't get confused) */

See meta:User:Omegatron/monobook.js.

[edit] CSS

/* Include css from en */

@import url(http://en.wikipedia.org/w/index.php?title=User:YOURUSERNAME/monobook.css&action=raw&ctype=text/css);

See meta:User:Omegatron/monobook.css

For Internet explorer' users:

/* Include css from es */

@import "http://es.wikipedia.org/w/index.php?title=Usuario:Axxgreazz/monobook.css&action=raw&ctype=text/css";

See en:User:Axxgreazz/monobook.css