MediaWiki:Gadget-validateBlockRollbackers.js/core.js: diferenças entre revisões
Conteúdo apagado Conteúdo adicionado
m |
m Minificando |
||
Linha 6: | Linha 6: | ||
* @date 15/apr/2012 |
* @date 15/apr/2012 |
||
* @updated 18/sep/2022 |
* @updated 18/sep/2022 |
||
* @source https://github.com/Nevallem/mw-gadget-validateBlockRollbackers |
|||
*/ |
*/ |
||
/* jshint laxbreak: true, esversion: 8 */ |
|||
/* global mw, $, URLSearchParams */ |
|||
!function(){"use strict";mw.messages.set({"vbr-noPermissionAutoconfirmed":"Como reversor voc\xea n\xe3o tem permiss\xe3o para bloquear esse usu\xe1rio, pois ele \xe9 um autoconfirmado.","vbr-noPermissionHimself":"Como reversor voc\xea n\xe3o tem permiss\xe3o para bloquear a si mesmo."});let e;async function o(){let o,i;return i=await (o=await fetch(mw.util.wikiScript("api")+"?"+new URLSearchParams({action:"query",list:"allusers",format:"json",auprop:"implicitgroups",aulimit:"1",aufrom:e.val(),auto:e.val()}))).json(),!$.isEmptyObject(i.query.allusers)&&-1!==$.inArray("autoconfirmed",i.query.allusers[0].implicitgroups)}function i(e,o){o?($(e).each(function(){-1===$(this).text().search(/((segundo|minuto|hora)s?|1 dia)/)&&$(this).remove()}),$(o).each(function(){(-1===$(this).text().search(/(vandalismo|Propaganda ou \[\[WP:SPAM|spam\]\]|Motivos de bloqueio comuns)/i)||-1!==$(this).text().indexOf("IP com longo hist\xf3rico"))&&$(this).remove()})):$(e).each(function(){(-1===$(this).text().search(/((segundo|minuto|hora)s?|1 dia)/)&&-1===$(this).text().search(/(vandalismo|Propaganda ou \[\[WP:SPAM|spam\]\]|Motivos de bloqueio comuns)/i)||-1!==$(this).text().indexOf("IP com longo hist\xf3rico"))&&$(this).remove()}),$('#mw-input-wpEditingRestriction label[role="radio"]').eq(1).remove(),$("#mw-htmlform-details").parent().parent().parent().remove(),$('input[name="wpExpiry-other"]').next().next().remove(),$('input[name="wpExpiry-other"]').remove(),$('input[name="wpReason-other"]').remove(),$('optgroup[label="Motivos predefinidos"]').remove()}async function t(){if(e.val()===mw.config.get("wgUserName")){$("#mw-content-text").html(mw.message("vbr-noPermissionHimself").plain());return}await o()&&$("#mw-content-text").html(mw.message("vbr-noPermissionAutoconfirmed").plain()),i.apply(void 0,"pt.m.wikipedia.org"!==location.hostname?[".oo-ui-defaultOverlay > div > div"]:['select[name="wpExpiry"] option','select[name="wpReason"] option']),e.blur(async()=>{await o()&&(alert(mw.message("vbr-noPermission"+(e.val()===mw.config.get("wgUserName")?"Himself":"Autoconfirmed")).plain()),e.val("").focus())})}$(function(){e=$('input[name="wpTarget"]'),t()})}(); |
|||
( function () { |
|||
'use strict'; |
|||
mw.messages.set( { |
|||
'vbr-noPermissionAutoconfirmed': 'Como reversor você não tem permissão para bloquear esse usuário, pois ele é um autoconfirmado.', |
|||
'vbr-noPermissionHimself': 'Como reversor você não tem permissão para bloquear a si mesmo.' |
|||
} ); |
|||
let $target; |
|||
/** |
|||
* Verify if the user is an autoconfirmed |
|||
* @return {jQuery.Deferred} |
|||
*/ |
|||
async function vbr_isAutoconfirmed() { |
|||
let requestResponse, requestData; |
|||
requestResponse = await fetch( mw.util.wikiScript( 'api' ) + '?' + new URLSearchParams( { |
|||
action: 'query', |
|||
list: 'allusers', |
|||
format: 'json', |
|||
auprop: 'implicitgroups', |
|||
aulimit: '1', |
|||
aufrom: $target.val(), |
|||
auto: $target.val() |
|||
} ) ); |
|||
requestData = await requestResponse.json(); |
|||
return $.isEmptyObject( requestData.query.allusers ) |
|||
? false |
|||
: ( $.inArray( 'autoconfirmed', requestData.query.allusers[ 0 ].implicitgroups ) !== -1 ); |
|||
} |
|||
/** |
|||
* Erase prohibited options to rollbackers |
|||
* @param {string} wpExpiryTarget |
|||
* @param {string} wpReasonTarget |
|||
* @return {undefined} |
|||
*/ |
|||
function vbr_eraseProhibitedOptions( wpExpiryTarget, wpReasonTarget ) { |
|||
if ( !wpReasonTarget ) { |
|||
$( wpExpiryTarget ).each( function() { |
|||
if ( $( this ).text().search( /((segundo|minuto|hora)s?|1 dia)/ ) === -1 |
|||
&& $( this ).text().search( /(vandalismo|Propaganda ou \[\[WP:SPAM|spam\]\]|Motivos de bloqueio comuns)/i ) === -1 |
|||
|| $( this ).text().indexOf( 'IP com longo histórico' ) !== -1 |
|||
) |
|||
$( this ).remove(); |
|||
} ); |
|||
} else { |
|||
$( wpExpiryTarget ).each( function() { |
|||
if ( $( this ).text().search( /((segundo|minuto|hora)s?|1 dia)/ ) === -1 ) |
|||
$( this ).remove(); |
|||
} ); |
|||
$( wpReasonTarget ).each( function() { |
|||
if ( $( this ).text().search( /(vandalismo|Propaganda ou \[\[WP:SPAM|spam\]\]|Motivos de bloqueio comuns)/i ) === -1 |
|||
|| $( this ).text().indexOf( 'IP com longo histórico' ) !== -1 |
|||
) |
|||
$( this ).remove(); |
|||
} ); |
|||
} |
|||
$( '#mw-input-wpEditingRestriction label[role="radio"]' ).eq( 1 ).remove(); |
|||
$( '#mw-htmlform-details' ).parent().parent().parent().remove(); |
|||
$( 'input[name="wpExpiry-other"]').next().next().remove(); |
|||
$( 'input[name="wpExpiry-other"]').remove(); |
|||
$( 'input[name="wpReason-other"]').remove(); |
|||
$( 'optgroup[label="Motivos predefinidos"]').remove(); |
|||
} |
|||
/** |
|||
* Executes |
|||
* @return {undefined} |
|||
*/ |
|||
async function vbr_run() { |
|||
if ( $target.val() === mw.config.get( 'wgUserName' ) ) { |
|||
$( '#mw-content-text' ).html( mw.message( 'vbr-noPermissionHimself' ).plain() ); |
|||
return; |
|||
} |
|||
if ( await vbr_isAutoconfirmed() ) { |
|||
$( '#mw-content-text' ).html( mw.message( 'vbr-noPermissionAutoconfirmed' ).plain() ); |
|||
} |
|||
vbr_eraseProhibitedOptions.apply( |
|||
undefined, |
|||
location.hostname !== 'pt.m.wikipedia.org' |
|||
? [ '.oo-ui-defaultOverlay > div > div' ] |
|||
: [ 'select[name="wpExpiry"] option', 'select[name="wpReason"] option' ] |
|||
); |
|||
$target.blur( async () => { |
|||
if ( await vbr_isAutoconfirmed() ) { |
|||
alert( mw.message( 'vbr-noPermission' + ( $target.val() === mw.config.get( 'wgUserName' ) ? 'Himself' : 'Autoconfirmed' ) ).plain() ); |
|||
$target.val( '' ).focus(); |
|||
} |
|||
} ); |
|||
} |
|||
$( function() { |
|||
$target = $( 'input[name="wpTarget"]' ); |
|||
vbr_run(); |
|||
} ); |
|||
}() ); |
Revisão das 17h23min de 18 de setembro de 2022
/**
* Validate block rollbackers
*
* @desc Prevents that rollbackers in ptwikipedia blocks autoconfirmed users and of exceed the block limit (1 day).
* @author [[w:pt:User:!Silent]]
* @date 15/apr/2012
* @updated 18/sep/2022
* @source https://github.com/Nevallem/mw-gadget-validateBlockRollbackers
*/
!function(){"use strict";mw.messages.set({"vbr-noPermissionAutoconfirmed":"Como reversor voc\xea n\xe3o tem permiss\xe3o para bloquear esse usu\xe1rio, pois ele \xe9 um autoconfirmado.","vbr-noPermissionHimself":"Como reversor voc\xea n\xe3o tem permiss\xe3o para bloquear a si mesmo."});let e;async function o(){let o,i;return i=await (o=await fetch(mw.util.wikiScript("api")+"?"+new URLSearchParams({action:"query",list:"allusers",format:"json",auprop:"implicitgroups",aulimit:"1",aufrom:e.val(),auto:e.val()}))).json(),!$.isEmptyObject(i.query.allusers)&&-1!==$.inArray("autoconfirmed",i.query.allusers[0].implicitgroups)}function i(e,o){o?($(e).each(function(){-1===$(this).text().search(/((segundo|minuto|hora)s?|1 dia)/)&&$(this).remove()}),$(o).each(function(){(-1===$(this).text().search(/(vandalismo|Propaganda ou \[\[WP:SPAM|spam\]\]|Motivos de bloqueio comuns)/i)||-1!==$(this).text().indexOf("IP com longo hist\xf3rico"))&&$(this).remove()})):$(e).each(function(){(-1===$(this).text().search(/((segundo|minuto|hora)s?|1 dia)/)&&-1===$(this).text().search(/(vandalismo|Propaganda ou \[\[WP:SPAM|spam\]\]|Motivos de bloqueio comuns)/i)||-1!==$(this).text().indexOf("IP com longo hist\xf3rico"))&&$(this).remove()}),$('#mw-input-wpEditingRestriction label[role="radio"]').eq(1).remove(),$("#mw-htmlform-details").parent().parent().parent().remove(),$('input[name="wpExpiry-other"]').next().next().remove(),$('input[name="wpExpiry-other"]').remove(),$('input[name="wpReason-other"]').remove(),$('optgroup[label="Motivos predefinidos"]').remove()}async function t(){if(e.val()===mw.config.get("wgUserName")){$("#mw-content-text").html(mw.message("vbr-noPermissionHimself").plain());return}await o()&&$("#mw-content-text").html(mw.message("vbr-noPermissionAutoconfirmed").plain()),i.apply(void 0,"pt.m.wikipedia.org"!==location.hostname?[".oo-ui-defaultOverlay > div > div"]:['select[name="wpExpiry"] option','select[name="wpReason"] option']),e.blur(async()=>{await o()&&(alert(mw.message("vbr-noPermission"+(e.val()===mw.config.get("wgUserName")?"Himself":"Autoconfirmed")).plain()),e.val("").focus())})}$(function(){e=$('input[name="wpTarget"]'),t()})}();