利用者:Infinite0694/Simple blocking tool.js
表示
お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。
多くの Windows や Linux のブラウザ
- Ctrl を押しながら F5 を押す。
Mac における Safari
Mac における Chrome や Firefox
- ⌘ Cmd と ⇧ Shift を押しながら R を押す。
詳細についてはWikipedia:キャッシュを消すをご覧ください。
/**
* Copy from [[w:User:Enterprisey/quick-vand-block.js]]
* User:Enterprisey/quick-vand-block.js
* [[w:Special:PermaLink/958655955]]
* @license
* @author [[w:en:User:Enterprisey]], @edit[[Infinite0694]]
*/
//<nowiki>
$.when( mw.loader.using( [ "mediawiki.api", "mediawiki.util" ] ), $.ready ).then( function () {
var api = new mw.Api();
var IP_BLOCK_LENGTH = "31 hours";
function go( obj ) {
obj.find( "span.mw-usertoollinks" ).each( function( idx, element ) {
$( element ).contents().last().before( " | ",
$( "<a>" )
.attr( "href", "#" )
.text( "無期限" )
.click( function () {
var username = $( this ).parent().get( 0 ).previousElementSibling.textContent;
if( confirm( "Block " + username ) ) {
var isAnon = $( this ).parent().get( 0 ).previousElementSibling.className.indexOf( "mw-anonuserlink" ) >= 0;
api.postWithToken( "csrf", {
action: "block",
user: username,
expiry: isAnon ? IP_BLOCK_LENGTH : "never",
reason: "[[WP:SOCK|sockpuppet]]",
nocreate: "true",
autoblock: "true",
noemail: "true"
} ).then( function () {
mw.notify( username + "をブロックしました");
} );
return false;
}
} ) );
} ) // end .each
} // end function go()
mw.hook( "wikipage.content" ).add( function ( obj ) { go( obj ); } );
} ); // end $.when handler
//</nowiki>