Usuário:Fabiojrsouza/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.
importScript("User:EpochFail/ArticleQuality.js");
/**
* Ferramenta de ajustes e traduções em referências (Script de ajustes)
*/
/* Autor: [[User:Luizdl/Script de ajustes.js|Luizdl]] */
mw.loader.load('//pt.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Usuário:Luizdl/Script de ajustes.js&action=raw&ctype=text/javascript', 'text/javascript');
/**
* Ferramenta de correção de referências feitas de modo incorreto (sem predef)
*/
/* Autor: [[:en:User:Zhaofeng_Li/reFill]] */
mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );
/**
* Ferramenta de melhora no bloqueio de vândalos
*/
/* Autor: [[User:!Silent/improveVandalBlock.js|!Silent]] */
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Usuário:!Silent/improveVandalBlock.js&action=raw&ctype=text/javascript' );
/* copiado de Usuário:!Silent/common.js */
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Usuário:!Silent/scripts.js&action=raw&ctype=text/javascript' );
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Usuário:!Silent/moreOptionsWatchlist.js&action=raw&ctype=text/javascript' );
/**
* Ferramenta para arquivar propostas de fusão
*/
/* Autor: [[User:!Silent/archiveMergingProposals.js|!Silent]] */
//mw.loader.load( '//pt.wikipedia.org/w/index.php?title=!Silent/archiveMergingProposals.js&action=raw&ctype=text/javascript' );
/**
* Ferramenta para melhorar as reversões
*/
/* Autor original: [[m:user:Hoo man|Hoo man]] <http://meta.wikimedia.org/wiki/User:Hoo_man/Scripts/Smart_rollback> */
/* Tradutor: [[User:EVinente/common.js|EVinente]] */
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Usuário:Tks4Fish/Smart Rollback.js&action=raw&ctype=text/javascript' );
/**
* Ferramenta para deleção em massa
*/
/* Autor: [[User:Leefeni de Karik/massdelete.js|Leefeni de Karik]] */
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Leefeni de Karik/massdelete.js&action=raw&ctype=text/javascript' );
/**
* Ferramenta para moção em massa
*/
/* Autor: [[User:Luan/massmove.js|Luan]] */
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Luan/massmove.js&action=raw&ctype=text/javascript' );
/**
* Ferramenta do Corretor Automático de Páginas ([[Wikipédia:Scripts/APC]])
*/
/* Autor: [[m:User:He7d3r/Tools/APC.js|He7d3r]] */
/* Origem das adições personalizadas: [[Usuário(a):OTAVIO1981/regraAPC.js|OTAVIO1981]], [[Usuário(a):OTAVIO1981/common.js|OTAVIO1981]], [[Wikipédia Discussão:Scripts/APC#Sugestão para as predefinições para textos noutros idiomas|Luan]] */
var userConf = { userRulesVersion: '0.1' };
userConf.userRules = [ {
name: 'Regras funcionando',
sub: [ {
name: 'citar web',
find: /\{{cite web/g,
replace: '{{citar web'
}, {
name: 'cite book',
find: /\{{cite book/g,
replace: '{{citar livro'
}, {
name: 'citar periódico',
find: /\{{cite journal/g,
replace: '{{citar periódico'
}, {
name: 'autor',
find: /\| *author/g,
replace: '|autor'
}, {
name: 'jornal',
find: /\| *journal/g,
replace: '|jornal'
}, {
name: 'título',
find: /\| *title/g,
replace: '|titulo'
}, {
name: 'acessodata',
find: /\| *accessdate/g,
replace: '|acessodata'
}, {
name: 'ano',
find: /\| *year/g,
replace: '|ano'
}, {
name: 'página',
find: /\| *page/g,
replace: '|página'
}, {
name: 'ultimo',
find: /\| *last/g,
replace: '|ultimo'
}, {
name: 'primeiro',
find: /\| *first/g,
replace: '|primeiro'
}, {
name: 'edição',
find: /\| *issue/g,
replace: '|número'
}, {
name: 'publicado',
find: /\| *publisher/g,
replace: '|publicado'
}, {
name: 'trabalho',
find: /\| *work/g,
replace: '|trabalho'
}, {
name: 'edição',
find: /\| *edition/g,
replace: '|edição'
}, {
name: 'caract',
find: /<ref[^>\/]*>[^]+?<\/ref>/gi,
replace: function (match){return match.replace(/[\uFFFD\u200A\u200B\u200D\u00AD\u0009\u0010\u0013\u007F\u0000-\u001F\u0080-\u009F]+/g, '')}
},
{
name: 'ponto_ref',
find: /(<ref>)((?:.*))(<\/ref>)([.|,])/g,
replace: '$4$1$2$3'
}]
}, {
name: 'Regras em teste',
sub: [ {
name: 'Remoção de LI em acessodata',
find: /(acessodata *= *)\[\[(\d{1,2}) de (\w+)\]\] de \[\[(\d{4})\]\]/g,
replace: '$1$2 de $3 de $4'
},
{
name: 'Sugestão para as predefinições para textos noutros idiomas',
find: /\{{lang\-/g,
replace: '{{langx|'
} ]
} ];
window.APC = $.extend( {}, window.APC, userConf );
// [[m:User:He7d3r/Tools/APC.js]] (workaround for [[phab:T35355]])
mw.loader.load( 'https://meta.wikimedia.org/w/index.php?title=User:He7d3r/Tools/APC-Loader.js&action=raw&ctype=text/javascript' );
//<nowiki>
/* Cat-a-lot - changes category of multiple files */
mw.loader.using(['jquery.ui', 'mediawiki.util'], function(){
mw.loader.load('//commons.wikimedia.org/w/load.php?modules=ext.gadget.Cat-a-lot');
});
////////// Cat-a-lot user preferences //////////
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":true,"docleanup":false,"subcatcount":10};
////////////////////////////////////catALotEnd//
//</nowiki>
// Ferramenta para resposta fácil em discussões
// Autor: [[:en:User:Enterprisey/reply-link.js|Enterprisey]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Enterprisey/reply-link-dev.js&action=raw&ctype=text/javascript' );
//EnhancedDelete
// Autor: Hoo man
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/enhancedDelete.js&action=raw&ctype=text/javascript');
/*Destaca as URLs mortas
* Autor: [[:de:Benutzer:Frog23/Dead Link Finder]]
*/
mw.loader.load("//tools.wmflabs.org/deadlinkfinder/script.js");
/**
* Ligações duplicadas
*/
/* Autor: [[:en:User:Ucucha/duplinks]] */
$( function($) {
return; // Exit for privacy reasons to avoid ReferenceError: wgNamespaceNumber is not defined. Can be removed when [[phab:T72470]] addressed.
if((wgNamespaceNumber !== 0) && (wgNamespaceNumber !== 2)) {
// only check links in mainspace and userspace (for userspace drafts)
return;
}
var portletlink = mw.util.addPortletLink('p-tb', '#', 'Destacar ligações duplicadas', 'ca-findduplicatelinks');
$(portletlink).click( function(e) {
e.preventDefault();
// create a separate div surrounding the lead
// first get the element immediately surrounding the article text. Unfortunately, MW doesn't seem to provide a non-fragile way for that.
var content = ".mw-content-ltr";
$(content).prepend(document.createElement('div'));
var lead = $(content).children()[0];
$(lead).attr('id', 'lead');
$(content).children().each( function() {
if(this.nodeName.toLowerCase() == 'h2') {
return false;
}
if($(this).attr('id') != 'lead') {
$(lead).append(this);
}
return true;
});
// detect duplicate links
mw.util.addCSS(".duplicate-link { border: 1px solid red; }");
var finddups = function() {
var href = $(this).attr('href');
if(href !== undefined && href.indexOf('#') !== 0) {
if(seen[href]) {
$(this).addClass("duplicate-link");
}
else {
seen[href] = true;
}
}
return true;
};
// array to keep track of whether we've seen a link before
var seen = [];
mw.util.$content.find('p a').not('#lead *, .infobox *, .navbox *').each(finddups);
mw.util.$content.find('#lead p a').not('.infobox *, .navbox *').each(finddups);
});
});
/**
* Archives merging proposals in Wikipédia:Fusão/Central de fusões page on Wikipédia PT
*
* @author [[w:pt:User:!Silent]]
* @date 03/aug/2016
* @update 28/dec/2019
*/
/* jshint laxbreak: true */
/* global jQuery, mediaWiki */
( function( mw, window, $ ) {
var amp,
api = new mw.Api();
// Messages
mw.messages.set( {
'amp-summary': 'Arquivando proposta de fusão encerrada, com um [[Usuário:!Silent/archiveMergingProposals.js|script]]',
'amp-archiveButton': 'Arquivar',
'amp-filing': 'Arquivando...',
'amp-filing-finished': 'Arquivamento terminado.',
'amp-archiveButton-title': 'Arquiva a proposta de fusão',
'amp-dialog-title': 'Arquivar proposta de fusão',
'amp-dialog-result': 'Resultado da proposta',
'amp-dialog-result-1': 'Aprovada',
'amp-dialog-result-2': 'Reprovada',
'amp-dialog-commentLabel': 'Comentário de encerramento da proposta',
'amp-dialog-commentPlaceholder': 'Não precisa assinar',
} );
/**
* @object amp
*/
amp = {
/**
* Messages
* @param {string} name Name of the message
* @param {string|number} [$N] Dynamic parameters to the message (i.e. the values for $1, $2, etc)
* @see [[mw:ResourceLoader/Default_modules#mediaWiki.message]]
* @return {string}
*/
message: function ( /*name[, $1[, $2[, ... $N ]]]*/ ) {
return mw.message.apply( this, arguments ).plain();
},
/**
* Edit function
* @param {object} info Edit params
* @return {jQuery.Deferred}
* @see see [[mw:API:Edit]]
*/
editPage: function( info ) {
var apiDeferred = $.Deferred(),
edit = function( value ) {
if ( $.isFunction( info.text ) ) {
info.text = info.text( value );
}
info.watchlist = 'preferences';
info.summary = amp.message( 'amp-summary' );
info.minor = true;
api.editPage( info ).done( function() {
apiDeferred.resolve( value );
} );
};
// If "info.text" is set and is a function, gets the page content first
// Set "info.getText" if you need get the content of another page other than "info.title"
if ( typeof info.getText === 'string' || $.isFunction( info.text ) ) {
api.getCurrentPageText( info.getText || info.title ).done( function( value ) {
edit( value );
} );
} else {
edit();
}
return apiDeferred.promise();
},
/**
* Stats edits
* @param {jQuery.Deferred} arguments The edits
* @example
amp.doEdits(
amp.editPage( info ) [,
amp.editPage( info ) [,
amp.editPage( info ) [,
...
] ] ] );
* @return {jQuery.Deferred}
*/
doEdits: function() {
return $.when.apply( this, Array.prototype.slice.call( arguments, 1 ) );
}
};
/**
* Archives the proposal
* @param {Array} pages
*/
amp.filing = function( pages, result ) {
var pagesIndex = 0,
merged = $( '#amp-result' ).val() === '1',
removeTemplate = function() {
amp.editPage( {
title: pages[ pagesIndex++ ],
text: function( value ) {
return value.replace( /\{\{fusão ?(de|com)?(\|.+)?\}\}\n?/i, '' );
}
} ).done( function() {
if ( pagesIndex < pages.length ) {
removeTemplate();
} else {
$( '#amp-filing' ).text( amp.message( 'amp-filing-finished' ) );
location.reload();
}
} );
};
$( '#amp-dialog label' ).after( '<br /><br /><div style="text-align: center;" id="amp-filing">' + amp.message( 'amp-filing' ) + '</div>' );
$( '.ui-dialog-buttonset button' ).eq( 0 ).remove();
$( '#amp-result' ).prop( 'disabled', true );
$( '#amp-comment' ).prop( 'disabled', true );
amp.doEdits(
amp.editPage( {
title: 'Wikipédia:Fusão/Central_de_fusões',
text: function( value ) {
return value.replace( '{' + '{fusões a avaliar|' + pages.join( '|' ) + '}}', '' );
}
} ),
amp.editPage( {
title: 'Wikipédia:Fusão/Central de fusões/' + pages.join( '; ' ),
text: function( value ) {
return value.replace( /(\|resultado ?=)/, '$1 ' + ( merged ? 'fundido' : 'não fundir' ) )
+ ( $( '#amp-comment' ).val() !== '' ? '\n\n' + $( '#amp-comment' ).val() + ' ~~' + '~~' : '' );
}
} ),
amp.editPage( {
title: 'Wikipédia:Fusão/Central_de_fusões/Arquivo_de_' + ( !merged ? 'não_' : '' ) + 'fundidas/' + ( new Date() ).getFullYear(),
appendtext: '\n* [[Wikipédia:Fusão/Central de fusões/' + pages.join( '; ' ) + ']]'
} )
).done( function() {
if ( merged ) {
$( '#amp-filing' ).text( amp.message( 'amp-filing-finished' ) );
location.reload();
return;
}
removeTemplate();
} );
};
/**
* Opens the prompt
* @param {Array} pages
*/
amp.prompt = function( pages ) {
$( '<div id="amp-dialog" class="ui-widget"></div>' ).dialog( {
title: amp.message( 'amp-dialog-title' ),
width: 'auto',
height: 'auto',
modal: true,
buttons: {
'OK': amp.filing.bind( undefined, pages ),
'Cancelar': function () {
$( '#amp-dialog' ).dialog( 'close' );
}
},
open: function () {
$( '.ui-dialog-titlebar-close' ).hide();
},
close: function () {
$( '#amp-dialog' ).dialog( 'destroy' ).remove();
}
} ).append( amp.message( 'amp-dialog-result' ) + ': '
+ '<select id="amp-result">'
+ '<option value="1">' + amp.message( 'amp-dialog-result-1' ) + '</option>'
+ '<option value="2">' + amp.message( 'amp-dialog-result-2' )+ '</option>'
+ '</select><br /><br />'
+ '<label>' + amp.message( 'amp-dialog-commentLabel' ) + ': <br /><textarea id="amp-comment" style="width: 300px;height: 200px;" placeholder="' + amp.message( 'amp-dialog-commentPlaceholder' ) + '" /></label>'
);
};
/**
* Init the script
*/
amp.init = function() {
$( 'h2' ).each( function( index ) {
$( this ).next().find( 'p' ).append( ' [',
$( '<a />', {
'class': 'amp-archiveButton',
'title': amp.message( 'amp-archiveButton-title' ),
'text': amp.message( 'amp-archiveButton' )
} ).click( amp.prompt.bind( undefined, $( this ).text().trim().split( /; ?/ ) ) ).css( 'cursor', 'pointer' ), ']'
);
} );
$( '.amp-archiveButton' ).tipsy();
};
if ( mw.config.get( 'wgPageName' ) === 'Wikipédia:Fusão/Central_de_fusões' ) {
mw.loader.using( [ 'ext.gadget.mediawiki.api.ptwiki', 'jquery.ui', 'jquery.tipsy' ], function () {
$( amp.init );
} );
}
}( mediaWiki, window, jQuery ) );
// [[Categoria:!Código-fonte de scripts|Arquivar propostas de fusão]]
// Don't watch new User or User Talk pages
// @author [[:w:pt:User:!Silent]]
// @author [[User:Tks4Fish]]
// @date 11/feb/2020
( function( window, $ ) {
'use strict';
$( function() {
if ( ( mw.config.get( 'wgNamespaceNumber' ) === 2 || mw.config.get( 'wgNamespaceNumber' ) === 3 ) && !!mw.util.getParamValue( 'redlink' ) )
$( '#wpWatchthis' ).prop( 'checked', false )
} );
}( window, jQuery ) );
// [[File:User:!Silent/improveVandalBlock.js]]
mw.loader.load( '//pt.wikipedia.org/w/index.php?title=Usuário:!Silent/improveVandalBlock.js&action=raw&ctype=text/javascript' );
// Provides several usefull functions for rollback (custom edit summary, mark as bot edits and mass revert)
// by [[m:user:Hoo man]] <https://meta.wikimedia.org/wiki/User:Hoo_man/smart_rollback.js>
// [[File:Hoo man/smart_rollback.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/smart_rollback.js&action=raw&ctype=text/javascript');
// [[File:User:He7d3r/Tools/ScoredRevisions.js]] (workaround for [[phab:T35355]])
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:He7d3r/Tools/ScoredRevisions.js&action=raw&ctype=text/javascript' );
// [[File:Krinkle_RTRC.js]]
mw.loader.load('ext.gadget.RTRC');
var userConf = { userRulesVersion: '0.1' };
userConf.userRules = [ {
name: 'Minhas correções',
sub: [
// https://regex101.com/r/CJjYd4/1
{ name: 'Simplifica ligações internas', find: /\[\[(.+?)\|\1\]\]/g, replace: '[[$1]]' },
// https://regex101.com/r/32MAsQ/1
{ name: 'Remove protocolo duplicado', find: /https?:\/\/(https?:\/\/)/g, replace: '$1' }
]
} ];
window.APC = $.extend( {}, window.APC, userConf );
// [[File:User:He7d3r/Tools/APC.js]] (workaround for [[phab:T35355]])
mw.loader.load( 'https://meta.wikimedia.org/w/index.php?title=User:He7d3r/Tools/APC-Loader.js&action=raw&ctype=text/javascript' );
var mesesEn = [ 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december', 'summer', 'spring', 'fall', 'autumn', 'winter'];
var mesesPt = [ 'janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro', 'verão', 'primavera', 'outono', 'outono', 'inverno'];
function tradMes(mes) {
for (var i = 0; i < mesesEn.length; i++) {
if (mes.toLocaleLowerCase() == mesesEn[i]
|| mes.toLocaleLowerCase() == mesesEn[i].substring(0, 3))
return mesesPt[i];
else if (mes.toLocaleLowerCase() == mesesPt[i])
return mes;
else if (mes.toLocaleLowerCase() == 'marco')
return 'março';
}
return 'falhou';
}
//datas
var cvGrauO = "([^\\|\\}]*°[^\\|\\}]*[\\|\\}])",
diaMesAno = "\\s*(\\d+(?:[–\\-\\/]\\d+|))\\s+([A-Za-zç]+)\\s+(\\d\\d\\d\\d?)\\.?",
linkDiaMesAno = "\\s*\\[\\[0?(\\d+(?:[–\\-\\/]\\d+|))\\s+de\\s+([A-Za-zç]+)\\]\\]\\s+de\\s+\\[?\\[?(\\d+)\\]?\\]?\\.?",
mesDiaAno = "\\s*([A-Za-zç]+)\\s+(\\d+(?:[–\\-\\/]\\d+|)),\\s+(\\d\\d\\d\\d?)",
mesAno = "\\s*([A-Za-zç]+),?\\s+(\\d\\d\\d\\d?)",
mesMesAno = "\\s*([A-Za-zç]+)\\s*[–\\-\\/]\\s*([A-Za-zç]+),?\\s*d?e?\\s+(\\d\\d\\d\\d?)",
nAnoMes = "\\s*(\\d\\d\\d\\d?)[\\-\\/](\\d\\d?)(\\s*\\|)",
nMesAno = "\\s*(\\d\\d?)[\\-\\/](\\d\\d\\d\\d?)(\\s*\\|)",
sAnoMesDia = "\\s*(\\d\\d\\d\\d?)[\\-\\/]([A-Za-z]+)[\\-\\/](\\d\\d?)(\\s*\\|)",
sDiaMesAno = "\\s*(\\d\\d?)[\\-\\/]([A-Za-z]+)[\\-\\/](\\d\\d\\d\\d?)(\\s*\\|)",
_0diaMesAno = "\\s*0(\\d+(?:[–\\-\\/]\\d+|))\\s+de\\s+([A-Za-zç]+)\\s+de\\s+(\\d\\d\\d\\d?)\\.?",
diaMesVAno = "\\s*\\[?\\[?(\\d\\d?(?:[–\\-\\/]\\d\\d?|))\\s+de\\s+([A-Za-zç]+)\\]?\\]?,?\\s+\\[?\\[?(\\d\\d\\d\\d?)\\]?\\]?\\.?",
prData = "\\s*\\{\\{\\s*[Dd]ata\\s*\\|\\s*(\\d\\d\\d\\d?)\\s*\\|\\s*(\\d\\d?)\\s*\\|\\s*(\\d\\d?)[^\{\}]*\\}\\}\\.?",
prDataExt = "\\s*\\{\\{[Dd]ataExt\\s*\\|\\s*(\\d\\d?)\\s*\\|\\s*(\\d\\d?)\\s*\\|\\s*(\\d\\d\\d\\d?)[^\{\}]*\\}\\}\\.?",
marco = "s*((:?\\d\\d?(?:[–\\-\\/]\\d\\d?|)[\\.º]?[º]?\\s+de\\s+|)[Mm]arco\\s+de\\s+\\d\\d\\d\\d?)\\.?";
//parâmetros
var data = "\\|\\s*(?:dat[ea]|year|ano)\\s*=",
transmissao = "\\|\\s*(?:transmissão|air\\-?date)\\s*=",
acessodata = "\\|\\s*(?:acc?esso?\\-?dat[ea]|acc?essadoem)\\s*=",
publicacao = "\\|\\s*(?:publication\\-?date|data\\-publica[cç][aã]o)\\s*=",
arquivodata = "\\|\\s*ar[cq][hu]iv[eo]\\-?dat[ea]\\s*=";
function rDatas(alt, padrao) {
if (alt.match(/falhou/)) return padrao;
else return alt;
}
function rdata(alt, padrao) {
return rDatas ('|data=' + alt, padrao);
}
function rtransmissao(alt, padrao) {
return rDatas ('|transmissão=' + alt, padrao);
}
function racessodata(alt, padrao) {
return rDatas ('|acessodata=' + alt, padrao);
}
function rpublicacao(alt, padrao) {
return rDatas ('|data-publicação=' + alt, padrao);
}
function rarquivodata(alt, padrao) {
return rDatas ('|arquivodata=' + alt, padrao);
}
citacoes = {
datas: { cond: [
/*{ reg: /\|\s*data\s*=\s*(\d+)\s*\|\s*ano\s*=\s*(\d+)\s*\|\s*mes=(\d+)/, subs: function(achou){
if (mesesPt[achou[3]-1])
return rdata(achou[1] + ' de ' + mesesPt[achou[3]-1] + ' de ' + achou[2], achou[0]);
else return achou[0];
} },*/
{ reg: /\|\s*(?:ano|year)\s*=\s*((:?\d\d?[\.º°]?[º°]?\s+de\s+|)[A-Za-zç]+\s+de\s+\d\d\d\d?)/, subs: function(achou){
return rdata(achou[1], achou[0]);
} }, {reg: /\|\s*(?:ano|year)\s*=\s*\[\[(\d\d\d\d?)\]\]/, subs: function(achou){
return '|ano=' + achou[1];
} }, { reg: new RegExp(data + cvGrauO), subs: function(achou){
return rdata(achou[1].replace('°', 'º'), achou[0]);
} }, { reg: new RegExp(data + marco), subs: function(achou){
return rdata(achou[1].replace(/[Mm]arco/, 'março'), achou[0]);
} }, { reg: new RegExp(data + diaMesAno), subs: function(achou){
return rdata(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(data + linkDiaMesAno), subs: function(achou){
return rdata(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(data + mesDiaAno), subs: function(achou){
return rdata(achou[2].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[1]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(data + mesAno), subs: function(achou){
return rdata(tradMes(achou[1]) + ' de ' + achou[2], achou[0]);
} }, { reg: new RegExp(data + mesMesAno), subs: function(achou){
return rdata(tradMes(achou[1]) + '–' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(data + nAnoMes), subs: function(achou){
if (mesesPt[achou[2]-1])
return rdata(mesesPt[achou[2]-1] + ' de ' + achou[1] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(data + nMesAno), subs: function(achou){
if (mesesPt[achou[1]-1])
return rdata(mesesPt[achou[1]-1] + ' de ' + achou[2] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(data + sAnoMesDia), subs: function(achou){
return rdata(achou[3] + ' de ' + tradMes(achou[2]) + ' de ' + achou[1] + achou[4], achou[0]);
} }, { reg: new RegExp(data + sDiaMesAno), subs: function(achou){
return rdata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3] + achou[4], achou[0]);
} }, { reg: new RegExp(data + _0diaMesAno), subs: function(achou){
return rdata(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(data + diaMesVAno), subs: function(achou){
return rdata(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(data + prData), subs: function(achou){
return rdata(achou[3] + ' de ' + mesesPt[achou[2]-1] + ' de ' + achou[1], achou[0]);
} }, { reg: new RegExp(data + prDataExt), subs: function(achou){
return rdata(achou[1] + ' de ' + mesesPt[achou[2]-1] + ' de ' + achou[3], achou[0]);
} },
{ reg: new RegExp(transmissao + cvGrauO), subs: function(achou){
return rtransmissao(achou[1].replace('°', 'º'), achou[0]);
} }, { reg: new RegExp(transmissao + diaMesAno), subs: function(achou){
return rtransmissao(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(transmissao + linkDiaMesAno), subs: function(achou){
return rtransmissao(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(transmissao + mesDiaAno), subs: function(achou){
return rtransmissao(achou[2].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[1]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(transmissao + mesAno), subs: function(achou){
return rtransmissao(tradMes(achou[1]) + ' de ' + achou[2], achou[0]);
} }, { reg: new RegExp(transmissao + mesMesAno), subs: function(achou){
return rtransmissao(tradMes(achou[1]) + '–' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(transmissao + nAnoMes), subs: function(achou){
if (mesesPt[achou[2]-1])
return rtransmissao(mesesPt[achou[2]-1] + ' de ' + achou[1] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(transmissao + nMesAno), subs: function(achou){
if (mesesPt[achou[1]-1])
return rtransmissao(mesesPt[achou[1]-1] + ' de ' + achou[2] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(transmissao + sAnoMesDia), subs: function(achou){
return rtransmissao(achou[3] + ' de ' + tradMes(achou[2]) + ' de ' + achou[1] + achou[4], achou[0]);
} }, { reg: new RegExp(transmissao + sDiaMesAno), subs: function(achou){
return rtransmissao(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3] + achou[4], achou[0]);
} }, { reg: new RegExp(transmissao + _0diaMesAno), subs: function(achou){
return rtransmissao(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(transmissao + prData), subs: function(achou){
return rtransmissao(achou[3] + ' de ' + mesesPt[achou[2]-1] + ' de ' + achou[1], achou[0]);
} }, { reg: new RegExp(transmissao + prDataExt), subs: function(achou){
return rtransmissao(achou[1] + ' de ' + mesesPt[achou[2]-1] + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(transmissao + diaMesVAno), subs: function(achou){
return rtransmissao(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} },
{ reg: new RegExp(acessodata + cvGrauO), subs: function(achou){
return racessodata(achou[1].replace('°', 'º'), achou[0]);
} }, { reg: new RegExp(acessodata + diaMesAno), subs: function(achou){
return racessodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(acessodata + mesDiaAno), subs: function(achou){
return racessodata(achou[2] + ' de ' + tradMes(achou[1]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(acessodata + linkDiaMesAno), subs: function(achou){
return racessodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(acessodata + prData), subs: function(achou){
return racessodata(achou[3] + ' de ' + mesesPt[achou[2]-1] + ' de ' + achou[1], achou[0]);
} }, { reg: new RegExp(acessodata + prDataExt), subs: function(achou){
return racessodata(achou[1] + ' de ' + mesesPt[achou[2]-1] + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(acessodata + diaMesVAno), subs: function(achou){
return racessodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(acessodata + nAnoMes), subs: function(achou){
if (mesesPt[achou[2]-1])
return racessodata('1 de ' + mesesPt[achou[2]-1] + ' de ' + achou[1] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(acessodata + nMesAno), subs: function(achou){
if (mesesPt[achou[1]-1])
return racessodata('1 de ' + mesesPt[achou[1]-1] + ' de ' + achou[2] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(acessodata + sAnoMesDia), subs: function(achou){
return racessodata(achou[3] + ' de ' + tradMes(achou[2]) + ' de ' + achou[1] + achou[4], achou[0]);
} }, { reg: new RegExp(acessodata + sDiaMesAno), subs: function(achou){
return racessodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3] + achou[4], achou[0]);
} }, { reg: new RegExp(acessodata + _0diaMesAno), subs: function(achou){
return racessodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(acessodata + "\\s*([A-Za-zç]+)\\s+,?d?e?\\s*(\\d\\d\\d\\d?)\\.?"), subs: function(achou){
return racessodata('1 de ' + tradMes(achou[1]) + ' de ' + achou[2], achou[0]);
} }, { reg: new RegExp(acessodata + marco), subs: function(achou){
return racessodata(achou[1].replace(/[Mm]arco/, 'março'), achou[0]);
} },
{ reg: new RegExp(publicacao + cvGrauO), subs: function(achou){
return rpublicacao(achou[1].replace('°', 'º'), achou[0]);
} }, { reg: new RegExp(publicacao + diaMesAno), subs: function(achou){
return rpublicacao(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(publicacao + mesDiaAno), subs: function(achou){
return rpublicacao(achou[2].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[1]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(publicacao + mesAno), subs: function(achou){
return rpublicacao(tradMes(achou[1]) + ' de ' + achou[2], achou[0]);
} }, { reg: new RegExp(publicacao + diaMesVAno), subs: function(achou){
return rpublicacao(achou[1].replace(/[\-\/]/, '–') + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(publicacao + mesAno), subs: function(achou){
return rpublicacao(tradMes(achou[1]) + ' de ' + achou[2], achou[0]);
} }, { reg: new RegExp(publicacao + mesMesAno), subs: function(achou){
return rpublicacao(tradMes(achou[1]) + '–' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(publicacao + nAnoMes), subs: function(achou){
if (mesesPt[achou[2]-1])
return rpublicacao(mesesPt[achou[2]-1] + ' de ' + achou[1] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(publicacao + nMesAno), subs: function(achou){
if (mesesPt[achou[1]-1])
return rpublicacao(mesesPt[achou[1]-1] + ' de ' + achou[2] + achou[3], achou[0]);
else return achou[0];
} }, { reg: new RegExp(publicacao + sAnoMesDia), subs: function(achou){
return rpublicacao(achou[3] + ' de ' + tradMes(achou[2]) + ' de ' + achou[1] + achou[4], achou[0]);
} }, { reg: new RegExp(publicacao + sDiaMesAno), subs: function(achou){
return rpublicacao(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3] + achou[4], achou[0]);
} }, { reg: new RegExp(publicacao + _0diaMesAno), subs: function(achou){
return rpublicacao(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} },
{ reg: new RegExp(arquivodata + cvGrauO), subs: function(achou){
return rarquivodata(achou[1].replace('°', 'º'), achou[0]);
} }, { reg: new RegExp(arquivodata + diaMesAno), subs: function(achou){
return rarquivodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(arquivodata + mesDiaAno), subs: function(achou){
return rarquivodata(achou[2] + ' de ' + tradMes(achou[1]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(arquivodata + diaMesVAno), subs: function(achou){
return rarquivodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }, { reg: new RegExp(arquivodata + sAnoMesDia), subs: function(achou){
return rarquivodata(achou[3] + ' de ' + tradMes(achou[2]) + ' de ' + achou[1] + achou[4], achou[0]);
} }, { reg: new RegExp(arquivodata + sDiaMesAno), subs: function(achou){
return rarquivodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3] + achou[4], achou[0]);
} }, { reg: new RegExp(arquivodata + _0diaMesAno), subs: function(achou){
return rarquivodata(achou[1] + ' de ' + tradMes(achou[2]) + ' de ' + achou[3], achou[0]);
} }
/*, { reg: /\|\s*dat[ea]\s*=data=\s*([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d?)/, subs: function(achou){
return '|data=' + tradMes(achou[1]) + ' de ' + achou[2];
} }*/
],
sumario: 'ajustando datas'
},
tradpred: { cond: [
{ reg: /\{\s*[Cc]ite ?web *(\s*\|)/, subs: function(achou){
return '{citar web' + achou[1];
} },
{ reg: /\{\s*[Cc]ite AV media notes *(\s*\|)/, subs: function(achou){
return '{citar vídeo notas' + achou[1];
} },
{ reg: /\{\s*[Cc]ite (?:video|AV media) *(\s*\|)/, subs: function(achou){
return '{citar vídeo' + achou[1];
} },
{ reg: /\{\s*[Cc]ite video game *(\s*\|)/, subs: function(achou){
return '{Citar jogo eletrônico';
} },
{ reg: /\{\s*[Cc]Cite thesis *(\s*\|)/, subs: function(achou){
return '{citar tese' + achou[1];
} },
{ reg: /\{\s*[Cc]ite magazine *(\s*\|)/, subs: function(achou){
return '{citar revista' + achou[1];
} },
{ reg: /\{\s*[Cc]ite report *(\s*\|)/, subs: function(achou){
return '{citar relatório' + achou[1];
} },
{ reg: /\{\s*[Cc]ite podcast *(\s*\|)/, subs: function(achou){
return '{citar podcast' + achou[1];
} },
{ reg: /\{\s*[Cc]ite news(?:paper|) *(\s*\|)/, subs: function(achou){
return '{citar jornal' + achou[1];
} },
{ reg: /\{\s*[Cc]ite map *(\s*\|)/, subs: function(achou){
return '{citar mapa' + achou[1];
} },
{ reg: /\{\s*[Cc]ite book *(\s*\|)/, subs: function(achou){
return '{citar livro' + achou[1];
} },
{ reg: /\{\s*[Cc]ite mailing list *(\s*\|)/, subs: function(achou){
return '{citar lista de discussão' + achou[1];
} },
{ reg: /\{\s*(?:[Cc]ite (?:journal|paper)|[Aa]rticle) *(\s*\|)/, subs: function(achou){
return '{citar periódico' + achou[1];
} },
{ reg: /\{\s*[Cc]ite newsgroup *(\s*\|)/, subs: function(achou){
return '{citar grupo de notícias' + achou[1];
} },
{ reg: /\{\s*[Cc]ite episode *(\s*\|)/, subs: function(achou){
return '{citar episódio' + achou[1];
} },
{ reg: /\{\s*[Cc]ite serial *(\s*\|)/, subs: function(achou){
return '{citar série' + achou[1];
} },
{ reg: /\{\s*[Cc]ite interview *(\s*\|)/, subs: function(achou){
return '{citar entrevista' + achou[1];
} },
{ reg: /\{\s*[Cc]ite encyclopedia *(\s*\|)/, subs: function(achou){
return '{citar enciclopédia' + achou[1];
} },
{ reg: /\{\s*[Cc]ite conference *(\s*\|)/, subs: function(achou){
return '{citar conferência' + achou[1];
} },
{ reg: /\{\s*[Cc]ite press(?: release|) *(\s*\|)/, subs: function(achou){
return '{citar comunicado de imprensa' + achou[1];
} },
{ reg: /\|\s*at\s*=/, subs: function(achou){
return '|em=';
} },
{ reg: /\|\s*accesso?\-?dat[ea]\s*=/, subs: function(achou){
return '|acessodata=';
} },
{ reg: /\|\s*date\s*=/, subs: function(achou){
return '|data=';
} },
{ reg: /\|\s*publication\-?date\s*=/, subs: function(achou){
return '|data-publicacao=';
} },
{ reg: /\|\s*air\-?date\s*=/, subs: function(achou){
return '|transmissão=';
} },
{ reg: /\|\s*archive\-?date\s*=/, subs: function(achou){
return '|arquivodata=';
} },
{ reg: /\|\s*archive\-?url\s*=/, subs: function(achou){
return '|arquivourl=';
} },
{ reg: /\|\s*agency\s*=/, subs: function(achou){
return '|agência=';
} },
{ reg: /\|\s*authors\s*=/, subs: function(achou){
return '|autores=';
} },
{ reg: /\|\s*people\s*=/, subs: function(achou){
return '|pessoas=';
} },
{ reg: /\|\s*credits\s*=/, subs: function(achou){
return '|créditos=';
} },
{ reg: /\|\s*book\-?title\s*=/, subs: function(achou){
return '|títulolivro=';
} },
{ reg: /\|\s*call\-?sign\s*=/, subs: function(achou){
return '|indicativo=';
} },
{ reg: /\|\s*cartography\s*=/, subs: function(achou){
return '|cartografia=';
} },
{ reg: /\|\s*chapter\s*=/, subs: function(achou){
return '|capítulo=';
} },
{ reg: /\|\s*article\s*=/, subs: function(achou){
return '|artigo=';
} },
{ reg: /\|\s*contribution\s*=/, subs: function(achou){
return '|contribuição=';
} },
{ reg: /\|\s*chapter\-format\s*=/, subs: function(achou){
return '|formato-capitulo=';
} },
{ reg: /\|\s*chapter\-?url\s*=/, subs: function(achou){
return '|capítulourl=';
} },
{ reg: /\|\s*coauthors?\s*=/, subs: function(achou){
return '|coautor=';
} },
{ reg: /\|\s*collaboration\s*=/, subs: function(achou){
return '|colaboração=';
} },
{ reg: /\|\s*conference\s*=/, subs: function(achou){
return '|conferencia=';
} },
{ reg: /\|\s*conference-format\s*=/, subs: function(achou){
return '|formato-conferencia=';
} },
{ reg: /\|\s*conference\-?url\s*=/, subs: function(achou){
return '|urlconferencia=';
} },
{ reg: /\|\s*contribution\s*=/, subs: function(achou){
return '|contribuição=';
} },
{ reg: /\|\s*degree\s*=/, subs: function(achou){
return '|grau=';
} },
{ reg: /\|\s*edition\s*=/, subs: function(achou){
return '|edição=';
} },
{ reg: /\|\s*editors\s*=/, subs: function(achou){
return '|editores=';
} },
{ reg: /\|\s*encyclopa?edia\s*=/, subs: function(achou){
return '|enciclopédia=';
} },
{ reg: /\|\s*episode\s*=/, subs: function(achou){
return '|episódio=';
} },
{ reg: /\|\s*format\s*=/, subs: function(achou){
return '|formato=';
} },
{ reg: /\|\s*language\s*=/, subs: function(achou){
return '|língua=';
} },
{ reg: /\|\s*interviewers?\s*=/, subs: function(achou){
return '|entrevistador=';
} },
{ reg: /\|\s*map\s*=/, subs: function(achou){
return '|mapa=';
} },
{ reg: /\|\s*map\-format\s*=/, subs: function(achou){
return '|formato-mapa=';
} },
{ reg: /\|\s*map\-url\s*=/, subs: function(achou){
return '|urlmapa=';
} },
{ reg: /\|\s*minutes\s*=/, subs: function(achou){
return '|minuto=';
} },
{ reg: /\|\s*network\s*=/, subs: function(achou){
return '|rede=';
} },
{ reg: /\|\s*orig\-?year\s*=/, subs: function(achou){
return '|anooriginal=';
} },
{ reg: /\|\s*pages\s*=/, subs: function(achou){
return '|páginas=';
} },
{ reg: /\|\s*page\s*=/, subs: function(achou){
return '|página=';
} },
{ reg: /\|\s*(?:number|issue)\s*=/, subs: function(achou){
return '|número=';
} },
{ reg: /\|\s*journal\s*=/, subs: function(achou){
return '|periódico=';
} },
{ reg: /\|\s*newspaper\s*=/, subs: function(achou){
return '|jornal=';
} },
{ reg: /\|\s*magazine\s*=/, subs: function(achou){
return '|revista=';
} },
{ reg: /\|\s*dictionary\s*=/, subs: function(achou){
return '|dicionário=';
} },
{ reg: /\|\s*work\s*=/, subs: function(achou){
return '|obra=';
} },
{ reg: /\|\s*place\s*=/, subs: function(achou){
return '|local=';
} },
{ reg: /\|\s*location\s*=/, subs: function(achou){
return '|local=';
} },
{ reg: /\|\s*publication\-?place\s*=/, subs: function(achou){
return '|local-publicação=';
} },
{ reg: /\|\s*publisher\s*=/, subs: function(achou){
return '|publicado=';
} },
{ reg: /\|\s*institution\s*=/, subs: function(achou){
return '|instituição=';
} },
{ reg: /\|\s*quote?a?t?i?o?n?\s*=/, subs: function(achou){
return '|citação=';
} },
{ reg: /\|\s*registration\s*=/, subs: function(achou){
return '|registro=';
} },
{ reg: /\|\s*section\s*=/, subs: function(achou){
return '|seção=';
} },
{ reg: /\|\s*season\s*=/, subs: function(achou){
return '|temporada=';
} },
{ reg: /\|\s*sections\s*=/, subs: function(achou){
return '|seções=';
} },
{ reg: /\|\s*sheet\s*=/, subs: function(achou){
return '|folha=';
} },
{ reg: /\|\s*sheets\s*=/, subs: function(achou){
return '|folhas=';
} },
{ reg: /\|\s*station\s*=/, subs: function(achou){
return '|estação=';
} },
{ reg: /\|\s*subscription\s*=/, subs: function(achou){
return '|subscrição=';
} },
{ reg: /\|\s*time\s*=/, subs: function(achou){
return '|tempo=';
} },
{ reg: /\|\s*time\-?caption\s*=/, subs: function(achou){
return '|lengenda=';
} },
{ reg: /\|\s*title\s*=/, subs: function(achou){
return '|título=';
} },
{ reg: /\|\s*title\-?link\s*=/, subs: function(achou){
return '|títulolink=';
} },
{ reg: /\|\s*episode\-?link\s*=/, subs: function(achou){
return '|episódiolink=';
} },
{ reg: /\|\s*department\s*=/, subs: function(achou){
return '|departamento=';
} },
{ reg: /\|\s*type\s*=/, subs: function(achou){
return '|tipo=';
} },
{ reg: /\|\s*trans\-?chapter\s*=/, subs: function(achou){
return '|capítulo-trad=';
} },
{ reg: /\|\s*transcript\-format\s*=/, subs: function(achou){
return '|transcricao-formato=';
} },
{ reg: /\|\s*transcript\s*=/, subs: function(achou){
return '|transcrição=';
} },
{ reg: /\|\s*transcript\-?url\s*=/, subs: function(achou){
return '|transcriçãourl=';
} },
{ reg: /\|\s*trans\-?title\s*=/, subs: function(achou){
return '|títulotrad=';
} },
{ reg: /\|\s*year\s*=/, subs: function(achou){
return '|ano=';
} },
{ reg: /\|\s*platform\s*=/, subs: function(achou){
return '|plataforma=';
} },
{ reg: /\|\s*version\s*=/, subs: function(achou){
return '|versão=';
} },
{ reg: /\|\s*scene\s*=/, subs: function(achou){
return '|cena=';
} },
{ reg: /\|\s*level\s*=/, subs: function(achou){
return '|fase=';
} },
{ reg: /\|\s*author(\d\d?)?\s*=/, subs: function(achou){
return '|autor' + (achou[1] ? achou[1] : '') + ' =';
} },
{ reg: /\|\s*author(\d\d?)?\-?link\s*=/, subs: function(achou){
return '|autorlink' + (achou[1] ? achou[1] : '') + ' =';
} },
{ reg: /\|\s*first(\d\d?)?\s*=/, subs: function(achou){
return '|primeiro' + (achou[1] ? achou[1] : '') + ' =';
} },
{ reg: /\|\s*last(\d\d?)?\s*=/, subs: function(achou){
return '|último' + (achou[1] ? achou[1] : '') + ' =';
} },
{ reg: /\|\s*editor(\d\d?)?\-last\s*=/, subs: function(achou){
return '|editor-sobrenome' + (achou[1] ? achou[1] : '') + ' =';
} },
{ reg: /\|\s*editor(\d\d?)?\-first\s*=/, subs: function(achou){
return '|editor-nome' + (achou[1] ? achou[1] : '') + ' =';
} },
{ reg: /\|\s*developer(\d\d?)?\s*=/, subs: function(achou){
return '|desenvolvedor' + (achou[1] ? achou[1] : '') + ' =';
} }
],
sumario: 'traduzindo nome/parâmetro'
},
geral: { cond: [
{ reg: /\|\s*accessadoem\s*=/, subs: function(achou){
return "|acessadoem=";
} },
{ reg: /\|\s*t[ií]tulo\s*=\s*([^\|\}]*[\S])(\s*[\|\}])/, subs: function(achou){
if (achou[1].match(/\u200B|\n/)) {
var tmp = achou[1].replace(/ *\n */g, ' ');
return '|título=' + tmp.replace(/\u200B/g, '') + achou[2];
}
return achou[0];
} },
{ reg: /\|\s*(?:l[ií]ngua[23]|lang)\s*=/, subs: function(achou){
return '|língua=';
} },
{ reg: /\|\s*(?:l[ií]ngua|idioma)\s*=\s*[Pp](?:ortugu[êe]s|ortuguese|t|t\-[Bb][Rr]|t\-[Pp][Tt])\s*([\|\}])/, subs: function(achou){
return achou[1];
} },
{ reg: /\|\s*[Ii][Dd]\s*=\s*ISBN/, subs: function(achou){
return '|isbn=';
} },
{ reg: /\{\s*[Rr]eferência a livro/, subs: function(achou){
return '{citar livro';
} },
{ reg: /\|\s*Ano\s*=/, subs: function(achou){
return '|ano=';
} },
{ reg: /\|\s*Autor\s*=/, subs: function(achou){
return '|autor=';
} },
{ reg: /\|\s*Autorlink\s*=/, subs: function(achou){
return '|autorlink=';
} },
{ reg: /\|\s*Editora\s*=/, subs: function(achou){
return '|editora=';
} },
{ reg: /\|\s*T[ií]tulo\s*=/, subs: function(achou){
return '|título=';
} },
{ reg: /\|\s*P[aá]gina\s*=/, subs: function(achou){
return '|página=';
} },
{ reg: /\|\s*P[aá]ginas\s*=/, subs: function(achou){
return '|páginas=';
} },
{ reg: /\|\s*Local de publicação\s*=/, subs: function(achou){
return '|local-publicação=';
} },
{ reg: /\|\s*Subt[ií]tulo\s*=/, subs: function(achou){
return '|subtítulo=';
} },
{ reg: /\|\s*Colec?[cç][aã]o\s*=/, subs: function(achou){
return '|coleção=';
} },
{ reg: /\|\s*N[uú]mero\s*=/, subs: function(achou){
return '|numero=';
} },
{ reg: /\|\s*Edição\s*=/, subs: function(achou){
return '|edição=';
} },
{ reg: /\|\s*Cap[ií]tulo\s*=/, subs: function(achou){
return '|capítulo=';
} },
{ reg: /\|\s*Notas\s*=/, subs: function(achou){
return '|notas=';
} },
{ reg: /\|\s*Volume\s*=/, subs: function(achou){
return '|volume=';
} },
{ reg: /\|\s*[Vv]olumes\s*=[^\|\[\{\}]*((?:\}\}|\|))/, subs: function(achou){
return achou[1];
} }
],
sumario: 'ajustes gerais'
},
duplicado: {
sumario: 'rm duplicados'
},
//predefinições com exclusividade de verificação
apenas: [ /\{\{\s*[Cc]itar web\s*\|/,
/\{\{\s*[Cc]itar vídeo(?: notas|)\s*\|/,
/\{\{\s*[Cc]itar tese\s*\|/,
/\{\{\s*[Cc]itar revista\s*\|/,
/\{\{\s*[Cc]itar relatório\s*\|/,
/\{\{\s*[Cc]itar podcast\s*\|/,
/\{\{\s*[Cc]itar periódico\s*\|/,
/\{\{\s*[Cc]itar mapa\s*\|/,
/\{\{\s*[Cc]itar livro\s*\|/,
/\{\{\s*[Rr]eferência a livro\s*\|/,
/\{\{\s*[Cc]itar lista de discussão\s*\|/,
/\{\{\s*[Cc]itar jornal\s*\|/,
/\{\{\s*[Cc]itar jogo eletrônico\s*\|/,
/\{\{\s*[Cc]itar notícia\s*\|/,
/\{\{\s*[Cc]itar grupo de notícias\s*\|/,
/\{\{\s*[Cc]itar episódio\s*\|/,
/\{\{\s*[Cc]itar entrevista\s*\|/,
/\{\{\s*[Cc]itar enciclopédia\s*\|/,
/\{\{\s*[Cc]itar discurso\s*\|/,
/\{\{\s*[Cc]itar conferência\s*\|/,
/\{\{\s*[Cc]itar comunicados? de imprensa\s*\|/,
/\{\{\s*[Cc]itar ar[Xx]iv\s*\|/,
/\{\{\s*[Cc]ite ?web\s*\|/,
/\{\{\s*[Cc]ite video(?: game|)\s*\|/,
/\{\{\s*[Cc]ite AV media(?: notes|)\s*\|/,
/\{\{\s*[Cc]ite thesis\s*\|/,
/\{\{\s*[Cc]ite magazine\s*\|/,
/\{\{\s*[Cc]ite report\s*\|/,
/\{\{\s*[Cc]ite podcast\s*\|/,
/\{\{\s*[Cc]ite news(?:paper|)\s*\|/,
/\{\{\s*[Cc]ite map\s*\|/,
/\{\{\s*[Cc]ite book\s*\|/,
/\{\{\s*[Cc]ite mailing list\s*\|/,
/\{\{\s*[Cc]ite journal\s*\|/,
/\{\{\s*[Cc]ite paper\s*\|/,
/\{\{\s*[Cc]ite newsgroup\s*\|/,
/\{\{\s*[Cc]ite episode\s*\|/,
/\{\{\s*[Cc]ite serial\s*\|/,
/\{\{\s*[Cc]ite interview\s*\|/,
/\{\{\s*[Cc]ite encyclopedia\s*\|/,
/\{\{\s*[Cc]ite conference\s*\|/,
/\{\{\s*[Cc]ite press(?: release|)\s*\|/,
/\{\{\s*[Cc]ite ar[xX]iv\s*\|/,
/\{\{\s*[Cc]itation\s*\|/,
/\{\{\s*[Aa]rticle\s*\|/
],
ordem: ['datas', 'tradpred', 'geral', 'duplicado']
}
function verifDuplicado(achou) {
function acharAninhados(cap) {
var colch = 0;
var chaves = 0;
var r= '';
for (var i = 0; i < cap.length; r += cap[i++]) {
if (cap.charAt(i) == '[' && cap.charAt(i + 1) == '[') {
if (chaves == 0) colch++;
r += cap[i++];
} else if (cap.charAt(i) == ']' && cap.charAt(i + 1) == ']') {
if (chaves == 0) colch--;
if (colch < 0) colch = 0;
r += cap[i++];
} else if (cap.charAt(i) == '{' && cap.charAt(i + 1) == '{') {
if (colch > 0) return achou[0];
chaves++;
r += cap[i++]
} else if (cap.charAt(i) == '}' &&
(cap.charAt(i + 1) == '}' || cap.charAt(i + 1) == ''))
{
// será < 0 se atingir o fim da delimitação
chaves--;
if (chaves < 0) {
if (colch == 0) return r;
else return achou[0];
}
r += cap[i++];
} else if (cap.charAt(i) == '|') {
if (colch == 0 && chaves == 0) return r;
}
}
if (colch == 0 && chaves == 0) return r;
else return achou[0];
}
var ultimo = acharAninhados(achou[4]);
if (ultimo == achou[0]) return achou[0];
if (/[^\s]+/.test(ultimo)) {
//o padrão do MediaWiki escolhe o último em caso de repetição, que se apague o primeiro
var primeiro = acharAninhados(achou[2]);
if (primeiro == achou[0]) return achou[0];
return achou[2].substring(primeiro.length) + achou[3] + achou[4];
} else {
//se o último for vazio, mesmo sendo o padrão escolhido, faz sentido removê-lo
return achou[1] + achou[2] + achou[4].substring(ultimo.length);
}
}
// apenas parâmetros das predefinições delimitadas
listaDupl = ['(?:acessodata|acessadoem)', 'data', 'obra', 'local', 'publicado', 't[ií]tulo'
, '(?:l[ií]ngua|idioma)', '(?:ligação inac?tiva|li|datali|urlmorta|dead\\-?url)'];
duplicado = [];
for (var i = 0; i < listaDupl.length; i++) {
duplicado.push({
reg: new RegExp("(\\|\\s*" + listaDupl[i] + "\\s*=)([\\s\\S]*)(\\|"
+ listaDupl[i] + "\\s*=)([\\s\\S]*)"),
subs: function(achou) {
return verifDuplicado(achou);
}
});
}
citacoes.duplicado.cond = duplicado;
links = [
{ reg: /<a\s*.*href\s*=\s*\"?([^\"&]*)\"?\s*[^&]*<\s*\/\s*a\s*>/, subs: function(achou){
var acao;
if (/\?/.test(achou[1])) acao = '&action=edit';
else acao = (/%3F/.test(achou[1])) ? '?&action=edit' : '?action=edit';
return achou[0] + ' <a href="javascript:subsTextoBox(window.open(\''
+ encodeURIComponent(achou[1]) + acao +'\'))">Editar</a>';
} },
{ reg: /<a\s*.*href\s*=\s*\"?([^\"&]*)\"?\s*.*<\s*\/\s*a\s*>/, subs: function(achou){
var acao;
if (/\?/.test(achou[1])) acao = '&action=edit';
else acao = (/%3F/.test(achou[1])) ? '?&action=edit' : '?action=edit';
return achou[0] + ' <a href="javascript:subsTextoBox(window.open(\''
+ encodeURIComponent(achou[1]) + acao +'\'))">Editar</a>';
} }
]
geral = [
{ reg: /\[\[(?:[Ff][Ii][Ll][Ee]|[Ii][Mm][Aa][Gg][Ee]):([^\[\]]*\]\])/, subs: function(achou){
return '[[Imagem:' + achou[1];
} }, { reg: /\[\[[Aa]nexo:([^\[\]]*\]\])/, subs: function(achou){
return '[[' + achou[1];
} }, { reg: /\[\[\s*([^\[\]]+)\s*\|\s*([^\[\]]+)\s*\]\]/, subs: function(achou){
var quot = '';
var tmp = (achou[2].charAt(0).toLocaleLowerCase() + achou[2].substring(1)).indexOf
(achou[1].charAt(0).toLocaleLowerCase() + achou[1].substring(1));
if (tmp != 0) {
quot = achou[2].match(/^(''')(.+)\1$/) || achou[2].match(/^('')(.+)\1$/) || achou[2].match(/^(')(.+)\1$/) || achou[2].match(/^(")(.+)\1$/);
if (! quot) return achou[0];
achou[2] = quot[2];
quot = quot[1];
tmp = (achou[2].charAt(0).toLocaleLowerCase() + achou[2].substring(1)).indexOf
(achou[1].charAt(0).toLocaleLowerCase() + achou[1].substring(1));
}
if (tmp == 0) {
var apos = achou[2].substring(achou[1].length);
if (/^[a-zàáâãçéêíòóôõúü]*[,\.;)]?$/.test(apos))
return quot + '[[' + achou[2].substring(0, achou[1].length)
+ ']]' + apos + quot;
}
return achou[0];
} }, { reg: /(<\s*ref\s+(?:[^<>]*\s+)?name=[^<>]+)\s*>\s*<\s*\/ref\s*>/, subs: function(achou){
return achou[1] + ' />';
} }, { reg: /\s*[\.,;]?\s*(<\s*ref(?:\s+[^<>]*)?>[^<>]*<\s*\/ref\s*>|<\s*ref\s+[^<>]*\/>) *([\.,;])/, subs: function(achou){
return achou[2] + achou[1];
} }, { reg: /Encyclopa?edia Britannica/, subs: function(achou){
return 'Encyclopædia Britannica';
} }, { reg: /([^\\=]) +\n/, subs: function(achou){
return achou[1] + '\n';
} }, { reg: /\{\{\s*(?:[Ll]igação inativa|[Ll]ink quebrado|[Dd]ead\s?link)\s*\|\s*dat[ea]\s*=\s*([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d?)/, subs: function(achou){
var tmp = tradMes(achou[1]);
if (tmp.match(/falhou/)) return achou[0];
else return '{{ligação inativa|data=' + tmp + ' de ' + achou[2];
} }, { reg: /\{\{\s*(?:[Dd]ead\s?link|[Ll]ink quebrado)\s*(\}\}|\|)/, subs: function(achou){
return '{{ligação inativa' + achou[1];
} }, { reg: /(\{\{\s*(?:[Cc]itar (?:web\s*\||vídeo\s*\||vídeo notas\s*\||tese\s*\||revista\s*\||relatório\s*\||podcast\s*\||periódico\s*\||mapa\s*\||livro\s*\||lista de discussão|jornal\s*\||notícia\s*\||grupo de notícias|episódio\s*\||entrevista\s*\||enciclopédia\s*\||discurso\s*\||conferência\s*\||comunicados? de imprensa|ar[Xx]iv\s*\|)|[Cc]itation\s*\|)[^\{]*)\}\}\s*\{\{\s*[Ll]igação inativa\s*(?:\|dat[ea]\s*=(\s*[A-Za-zç]+\s+de\s*\d\d\d\d?)\s*|)(?:\|\s*bot=[^\}]*|)\}\}/, subs: function(achou){
return achou[1] + '|datali=' + (achou[2] ? achou[2] : mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear()) + '}}';
} }, { reg: /\{\{\s*(?:[Mm]\-notas|[Mm]\-fontes|[Mm]ais\-?notas|[Mm]ais[ \-]?fontes|[Pp]oucas fontes|[Ff]altam fontes)\s*(\}\}|\|)/, subs: function(achou){
return '{{mais notas' + achou[1];
} }, { reg: /\{\{\s*(?:[Ff]ormatação|[Rr]eciclar|[Cc]leanup)\s*(\}\}|\|)/, subs: function(achou){
return '{{reciclagem' + achou[1];
} }, { reg: /\{\{\s*(?:[Cc]itation needed|[Ff]act|[Cc]arece de fonte|[Cc]arece\-de\-fontes|[Cc]arece fontes|[Ss]em fontes|[Cc]itação necessária|[Cc]ite as fontes)\s*(\}\}|\|)/, subs: function(achou){
return '{{carece de fontes' + achou[1];
} }, { reg: /\{\{\s*[Ss]em\-notas\s*(\}\}|\|)/, subs: function(achou){
return '{{sem notas' + achou[1];
} }, { reg: /\{\{\s*(?:[Mm](?:ais|)\-fontes-bpv|[Mm]ais\-notas\-bpv)\s*(\}\}|\|)/, subs: function(achou){
return '{{mais notas-bpv' + achou[1];
} }, { reg: /\{\{\s*([Cc]arece de fontes2?|[Rr]eciclagem|[Ss]em\-fontes|[Ss]em notas|[Mm]ais notas|[Mm]ais notas\-bpv|[Ll]igação inativa|[Mm]ultitag)((?:\|[^\{\}]*))?\|\s*dat[ea]\s*=\s*([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d?)/, subs: function(achou){
var tmp = tradMes(achou[3]) + ' de ' + achou[4];
if (tmp.match(/falhou/)) return achou[0];
else return '{{' + achou[1] + (achou[2] ? achou[2] : '') + '|data=' + tmp;
} }, { reg: /\{\{\s*[Ss]\-fontes\s*\|\s*dat[ea]\s*=\s*([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d?)/, subs: function(achou){
var tmp = tradMes(achou[1]);
if (tmp.match(/falhou/)) return achou[0];
else return '{{sem-fontes|data=' + tmp + ' de ' + achou[2];
} }, { reg: /\{\{\s*[Ff]\-referências\s*\|\s*dat[ea]\s*=\s*([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d?)/, subs: function(achou){
var tmp = tradMes(achou[1]);
if (tmp.match(/falhou/)) return achou[0];
else return '{{formatar referências|data=' + tmp + ' de ' + achou[2];
} }, { reg: /\{\{\s*wkf\s*\|\s*dat[ea]\s*=\s*([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d)/, subs: function(achou){
var tmp = tradMes(achou[1]);
if (tmp.match(/falhou/)) return achou[0];
else return '{{wikificação|data=' + tmp + ' de ' + achou[2];
} }, { reg: /\{\{\s*(?:[Mm]\-notas|[Mm]\-fontes)\s*\}\}/, subs: function(achou){
return '{{mais notas|data='+ mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear()+'}}';
} }, { reg: /\{\{\s*[Ss]\-fontes\s*\}\}/, subs: function(achou){
return '{{sem-fontes|data='+ mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear()+'}}';
} }, { reg: /\{\{\s*[Ff]\-referências\s*\}\}/, subs: function(achou){
return '{{formatar referências|data='+ mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear()+'}}';
} }, { reg: /\{\{\s*wkf\s*\}\}/, subs: function(achou){
return '{{wikificação|data='+ mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear()+'}}';
} }, { reg: /\{\{\s*([Cc]arece de fontes|[Rr]eciclagem|[Ss]em\-fontes|[Ss]em notas|[Mm]ais notas|[Mm]ais notas\-bpv|[Ll]igação inativa|[Mm]ultitag)\s*((?:\|[^\{\}]*)?\}\})/, subs: function(achou){
if (achou[2].match(/\|\s*[Dd]at[ae]\s*=/)) return achou[0];
tmpReg = /(?:\||(?:\|[Dd]esde|[Dd]at[ea])\s*=?|=)\s*(?:\d\d?\s+d?e?\s*)?([A-Za-zç]+)\s+d?e?\s*(\d\d\d\d)\s*(\||\}\})/;
var tmp = achou[2].match(tmpReg);
if(tmp) {
tmp = '|data=' + tradMes(tmp[1]) + ' de ' + tmp[2] + tmp[3];
if (! tmp.match(/falhou/)) return '{{' + achou[1] + achou[2].replace(tmpReg, tmp);
}
return '{{' + achou[1] + '|data='+ mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear() + achou[2];
} }, { reg: /\{\{\s*([Cc]arece de fontes\/bloco|[Cc]arece de fontes2)\s*((?:\|[^\{\}]*)?\}\})/, subs: function(achou){
if (achou[2].match(/\|\s*[Dd]at[ae]\s*=/)) return achou[0];
return '{{' + achou[1] + '|data='+ mesesPt[(new Date).getMonth()]
+ ' de ' + (new Date).getFullYear() + achou[2];
} }, { reg: /\{\{\s*(?:[Ll]igações [Ee]xternas|[Pp]áginas externas|[Rr]eferências externas|[Ll]inks|[Ll]ink externo|[Ll]igação externa|[Ll]inks externos)\s*\}\}/, subs: function(achou){
return 'Ligações externas';
} }, { reg: /\{\{\s*[Vv]e(?:r|ja) [Tt]ambém\s*\}\}/, subs: function(achou){
return 'Ver também';
} }, { reg: /\{\{\s*[Bb]ibliografia\s*\}\}/, subs: function(achou){
return 'Bibliografia';
} }, { reg: /\n? *(\n)? *\{\{(?:[Ss]em ?interwikis?|[Ss]eminterwiki-categorias|[Ss]emiwcat|[Ss]em[ \-]?iw)\s*(?:\|[^\{\}]*)?\}\} *(\n?) *\n/, subs: function(achou){
return '\n' + ((achou[1] || achou[2]) ? '\n' : '');
} }, { reg: /\{\{(?:[Ss]em ?interwikis?|[Ss]eminterwiki-categorias|[Ss]emiwcat|[Ss]em[ \-]?iw)\s*(?:\|[^\{\}]*)?\}\}([^\n])/, subs: function(achou){
return achou[1];
} } ]
// { reg: /\{\{\s*[Cc]itar not[ií]cia *(\n?) *\|/, subs: function(achou){
// return '{{citar jornal' + (achou[1] ? achou[1] : '') + '|';
//} }
//predefinições com exceção de verificação
excecoes = [];
function substComExcecao(texto, cond, excecoes) {
var tmp = '';
for (var j = 0; j < cond.length; j++) {
while (texto) {
var pos = texto.search(cond[j].reg);
while (excecoes.length > 0 && pos != -1) {
var exce = -1;
for (var i = 0; i < excecoes.length; i++) {
var _exce = texto.search(excecoes[i]);
if ((exce == -1) || (_exce != -1 && _exce < exce))
exce = _exce;
}
if (exce == -1) {
pos = texto.search(cond[j].reg);
break;
}
if (pos < exce){
pos = texto.search(cond[j].reg);
break;
}
var bloco = 0;
var exceInicial = exce;
for (; exce < texto.length; exce++) {
if (texto.charAt(exce) == '{' && texto.charAt(exce + 1) == '{') {
bloco++;
exce++; //O próximo char já foi verificado
}
else if (texto.charAt(exce) == '}' && texto.charAt(exce + 1) == '}') {
bloco--;
exce++; //O próximo char já foi verificado
}
if (bloco == 0) break;
}
if (bloco != 0) {
var linhas = (tmp + texto.substring(0, exceInicial)).split('\n');
mw.notify("Erro: O bloco da predefinição na linha: " + linhas.length
+ ", e posição: " + (linhas[linhas.length -1].length +1) + " nunca é fechado");
undefined.pararExecucao = 0;
}
tmp += texto.substring(0, exce);
texto = texto.substring(exce);
pos = texto.search(cond[j].reg);
}
if (pos > -1) {
tmp += texto.substring(0, pos);
texto = texto.substring(pos);
var achou = texto.match(cond[j].reg);
texto = texto.replace(achou[0], '');
tmp += cond[j].subs(achou);
} else {
tmp += texto;
texto = "";
}
}
texto = tmp;
tmp = '';
}
return texto;
}
function substApenas(texto, cond, apenas, excecoes) {
var tmp = '';
while (texto) {
var apen = -1;
for (var i = 0; i < apenas.length; i++) {
var _apen = texto.search(apenas[i]);
if ((apen == -1) || (_apen != -1 && _apen < apen))
apen = _apen;
}
if (apen == -1) {
tmp += texto;
texto = '';
break;
}
var bloco = 1;
var apenInicial = apen;
for (++apen; apen < texto.length; apen++) {
if (texto.charAt(apen) == '{' && texto.charAt(apen + 1) == '{') {
bloco++;
apen++; //O próximo char já foi verificado
}
else if (texto.charAt(apen) == '}' && texto.charAt(apen + 1) == '}') {
bloco--;
apen++; //O próximo char já foi verificado
}
if (bloco == 0) break;
}
if (bloco != 0) {
var linhas = (tmp + texto.substring(0, apenInicial)).split('\n');
mw.notify("Erro: O bloco da predefinição na linha: " + linhas.length
+ ", e posição: " + (linhas[linhas.length -1].length +1) + " nunca é fechado");
undefined.pararExecucao = 0;
}
if (excecoes) {
apenInicial++;
tmp += texto.substring(0, apenInicial)
+ substComExcecao(texto.substring(apenInicial, apen), cond, excecoes)
} else tmp += texto.substring(0, apenInicial)
+ substituir(texto.substring(apenInicial, apen), cond);
texto = texto.substring(apen);
}
return tmp;
}
function substituir(texto, cond) {
var tmp = '';
for (var j = 0; j < cond.length; j++) {
while (texto) {
var pos = texto.search(cond[j].reg);
if (pos > -1) {
tmp += texto.substring(0, pos);
texto = texto.substring(pos);
var achou = texto.match(cond[j].reg);
texto = texto.replace(achou[0], '');
tmp += cond[j].subs(achou);
} else {
tmp += texto;
texto = "";
}
}
texto = tmp;
tmp = '';
}
return texto;
}
function subsTextoBox(janela) {
if (janela == window) _();
else $(janela).load(_);
function _(){
var box = janela.document.getElementById('wpTextbox1');
var temp = box.value;
var mudou = {};
var sumario = '';
var comp;
var escape = 0;
var aviso = false;
{ // Verificar se há blocos não fechados
var bloco = 0;
var pbloco = 0;
for (var pos = 0; pos < temp.length; pos++) {
if (temp.charAt(pos) == '<') {
var partes = 0;
var identif = ['math', 'nowiki'];
var palavra = '';
pos++
escopo: while (pos < temp.length) {
switch(partes) {
case 0:
if (/^\s$/.test(temp.charAt(pos))) {
pos++;
continue escopo;
}
partes++;
break;
case 1:
var c = temp.charAt(pos).toLowerCase();
if (/^[a-z]$/.test(c)) {
palavra += c;
pos++;
partes++
continue escopo;
} else break escopo;
break;
case 2:
var c = temp.charAt(pos).toLowerCase();
if (/^[a-z]$/.test(c)) {
palavra += c;
pos++;
continue escopo;
} else partes++;
break;
case 3:
for (var i = 0; i < identif.length; i++) {
if (palavra == identif[i]) {
partes++;
break;
}
}
if (partes == 3) break escopo;
break;
case 4:
if (temp.charAt(pos) == '>') partes++;
pos++;
break;
case 5:
if (temp.charAt(pos) == '<') partes++;
pos++;
break;
case 6:
var b = false;
if (/^[\s\/]$/.test(temp.charAt(pos))) {
if (temp.charAt(pos) == '/') {
if (b) {
partes = 5;
} else b = true;
}
pos++;
continue escopo;
}
partes++;
break;
case 7:
for (var num = 0; num < palavra.length; num++) {
if (palavra[num] != temp.charAt(pos).toLowerCase()) {
partes = 5;
break;
}
pos++
}
if (partes == 7) partes++;
break;
case 8:
if (/^[^>]$/.test(temp.charAt(pos))) pos++;
else {pos++; break escopo}
break;
}
}
}
if (temp.charAt(pos) == '{' && temp.charAt(pos + 1) == '{') {
if (bloco == 0) pbloco = pos;
bloco++;
pos++; //O próximo char já foi verificado
} else if (temp.charAt(pos) == '}' && temp.charAt(pos + 1) == '}') {
bloco--;
pos++; //O próximo char já foi verificado
}
if (bloco == -1) {
var linhas = temp.substring(0, pos).split('\n');
document.getElementById("editpage-copywarn").innerHTML += "<div style='color: red'>Aviso:</div> Na linha: " + linhas.length + ", e posição: " + linhas
[linhas.length -1].length + " teve bloco fechado sem nenhum aberto. Para "
+ "ignorar clique em 'Mostrar alterações'";
aviso = true;
bloco = 0;
}
}
if (bloco != 0) {
var linhas = temp.substring(0, pbloco).split('\n');
mw.notify("Erro: O bloco da predefinição na linha: " + linhas.length
+ ", e posição: " + (linhas[linhas.length -1].length +1) + " nunca é fechado");
return;
}
}
for (var i = 0; i < citacoes.ordem.length; i++) {
var obj = citacoes[citacoes.ordem[i]];
escape = 0;
do {
if (escape == 6) {
mw.notify('Parece haver algo errado na operação: '
+ obj.sumario + '. Parando a execução');
return;
}
escape++;
comp = temp;
temp = substApenas(temp, obj.cond, citacoes.apenas, [/\{\{/]);
if ((! mudou[citacoes.ordem[i]]) && comp != temp) {
mudou[citacoes.ordem[i]] = true;
if (sumario)
sumario += ', ';
sumario += obj.sumario;
}
} while(comp != temp)
}
if (sumario) sumario += ' nas citações';
escape = 0;
do {
if (escape == 8) {
mw.notify("Parece haver algo errado ao aplicar ajustes gerais. Parando a execução");
return;
}
escape++;
comp = temp;
temp = substituir(temp, geral);
if ((! mudou.outros) && comp != temp) {
mudou.outros = true;
if (sumario != '')
sumario += ', outros ';
sumario += 'ajustes';
}
} while(comp != temp)
box.value = temp;
if (sumario != '')
sumario += ' usando [[user:Luizdl/Script de ajustes.js|script]]';
{
var tmpSmr = janela.document.getElementById('wpSummary').value;
if (tmpSmr) sumario += (sumario ? ', ' : '') + tmpSmr;
}
janela.document.getElementById('wpSummary').value = sumario;
janela.document.getElementById('wpMinoredit').checked = true;
if (! aviso) {
//janela.document.getElementById('wpPreview').click();
janela.document.getElementById('wpDiff').click();
//janela.document.getElementById('wpSave').click();
}
}
}
var categoria;
var afluentes;
if (categoria = document.getElementById('mw-pages')) {
if (categoria = categoria.getElementsByClassName('mw-content-ltr')[0]) {
fCategoria = function() {
categoria.innerHTML = substituir(categoria.innerHTML, links);
}
categoria.innerHTML = '<input type="button" value="Criar links de edição automática" onclick ="fCategoria()" ><br>' + categoria.innerHTML
}
} else if (afluentes = document.getElementById("mw-whatlinkshere-list")) {
fAfluentes = function() {
afluentes.innerHTML = substituir(afluentes.innerHTML, links)
}
afluentes.innerHTML = '<input type="button" value="Criar links de edição automática" onclick ="fAfluentes()" ><br>' + afluentes.innerHTML
//afluentes.innerHTML = substituir(afluentes.innerHTML, links);
} else if (document.getElementById('wpTextbox1')) {
document.getElementById('wpDiff').outerHTML =
document.getElementById('wpDiff').outerHTML.replace('accesskey="v"', 'accesskey="d"')
.replace('alt-shift-v', 'alt-shift-d')
+ '\n<input id="Ajustes automáticos" '
+ 'name="Ajustes automáticos" tabindex="7" title="Ajustes automáticos [alt-shift-a]" '
+ 'type="button" value="Ajustes automáticos" accesskey="a" onclick="subsTextoBox(window)">';
// subsTextoBox(window)
}
mw.loader.load("//en.wikipedia.org/w/index.php?title=User:The_Earwig/permalink.js&action=raw&ctype=text/javascript");