MediaWiki:Common.js
De Letropédia
Nota: Após publicar, você pode ter que limpar o "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)
- Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
- Opera: Pressione Ctrl-F5.
document.addEventListener("DOMContentLoaded", function () {
if (mw.config.get('wgPageName') === "Special:UserLogin") {
window.location.href = "https://letrasmais.net.br/index.php?letras=login";
}
});
mw.loader.using( [ 'mediawiki.api', 'mediawiki.util' ] ).then( function () {
var container = document.getElementById( 'lista-paginas-recentes' );
if ( !container ) {
return;
}
var api = new mw.Api();
api.get( {
action: 'query',
list: 'recentchanges',
rctype: 'new',
rcnamespace: 0, // Apenas artigos do domínio principal (exclui Ajuda:, Predefinição:, etc.)
rcshow: '!bot|!redirect', // Ignora redirecionamentos e edições de robôs
rclimit: 10, // Quantidade de links exibidos
formatversion: 2
} ).done( function ( data ) {
var changes = data.query && data.query.recentchanges ? data.query.recentchanges : [];
if ( changes.length === 0 ) {
container.textContent = 'Nenhuma página recente encontrada.';
return;
}
var ul = document.createElement( 'ul' );
changes.forEach( function ( item ) {
var li = document.createElement( 'li' );
var a = document.createElement( 'a' );
a.href = mw.util.getUrl( item.title );
a.textContent = item.title;
li.appendChild( a );
ul.appendChild( li );
} );
container.innerHTML = '';
container.appendChild( ul );
} ).fail( function () {
container.textContent = 'Não foi possível carregar as páginas recentes.';
} );
} );