MediaWiki:Common.js
Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Internet Explorer / Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
- Opera: Pressione Ctrl-F5.
/*jshint strict:false*/
/*global mw, $, importScript, importStylesheet*/
/**
* @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @revision 2020-04-04
*/
mw.loader.using( ['mediawiki.util'], function () {
var extraCSS = mw.util.getParamValue( 'withCSS' ),
extraJS = mw.util.getParamValue( 'withJS' );
if ( extraCSS ) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) {
mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraCSS ) + '&action=raw&ctype=text/css', 'text/css' );
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
}
}
if ( extraJS ) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) {
mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraJS ) + '&action=raw&ctype=text/javascript' );
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
}
}
});
/**
* Variável global para uso em scripts que lidam com o nome dos livros
* @source: [[:en:MediaWiki:Gadget-predef.js]]
* @author: [[:en:User:Whiteknight]]
* @author: Helder (https://github.com/he7d3r)
* @example: 'A:B:C:D/E:F:G:H/I:J:K:L' -> 'A:B:C:D' -> 'A:B'
* @see: [[MediaWiki:Gadget-Common.js]] (alterações deste código devem ser duplicadas lá, para que seja usada pelos Gadgets)
*/
mw.config.set('wgBookName', mw.config.get('wgPageName').split('/', 1)[0] || mw.config.get('wgPageName'));
mw.config.set('wgBookName', mw.config.get('wgBookName').split(':', 2).join(':'));
// [[Categoria:Scripts do Wikilivros|Common.js]]