Usuário:Joalpe/common.js

Origem: Wikipédia, a enciclopédia livre.

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.
/**
 * 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');

/* Adds a toolbox link to do a copyvio check on the given page. */
mw.loader.using("mediawiki.util", function() {
    mw.util.addPortletLink(
        "p-tb",
        "https://tools.wmflabs.org/copyvios/?lang=" + mw.config.get("wgContentLanguage") + "&project=" + "wikipedia" + "&title=" + encodeURIComponent(mw.config.get("wgPageName")),
        "Copyvio check",
        "t-copyvio-check",
        "Check this page for copyright violations"
    );
    mw.util.addPortletLink(
        "p-tb",
        "https://refill.toolforge.org/ng/result.php?defaults=y&wiki=pt&page=" + encodeURIComponent(mw.config.get("wgPageName")),
        "reFill 2",
        "t-refill-two",
        "Formatar referências"
    );
});

/* ORES. */
importScript("User:EpochFail/ArticleQuality.js");

/**
 * Warning on unsigned comments
 * @author: Helder (https://github.com/he7d3r)
 * @license: CC BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0/>
 */
( function ( mw, $ ) {
	'use strict';

	function validateComments() {
		$( '#wpSave' ).on( 'click', function ( e ) {
			var $textBox = $( '#wpTextbox1' ),
				curText = $textBox.val(),
				signRequired = mw.config.get( 'wgNamespaceNumber' ) % 2 === 1
					|| curText.indexOf( ' (' + 'UTC)' ) !== -1,
				hasSignature = /~{4}(?!<\/nowiki>)/.test( curText ),
				unsignedText = 'Parece que esqueceu de colocar "~~' + '~~" no final da mensagem para assinar o seu comentário. Deseja salvar mesmo assim?';
			if ( signRequired && !hasSignature && !confirm( unsignedText ) ) {
				$textBox.focus();
				e.preventDefault();
				mw.log( 'Não salvar' );
			}
		} );
	}
	if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
		$( validateComments );
	}

}( mediaWiki, jQuery ) );