User:-Zest

From Wikipedia!
Jump to navigation Jump to search

$(mw.util.addPortletLink('p-cactions', '#', '一鍵封禁', 'p-onekeyblock')).click(function (e) {

   e.preventDefault();
   var username = prompt('封誰?');
   if (username) {
       $.ajax({
           url: mw.util.wikiScript('api'),
           data: {
               format: 'json',
               action: 'block',
               user: username,
               expiry: 'never',
               reason: 'by 一鍵封禁',
               nocreate: true,
               autoblock: true,
               noemail: true,
               reblock: true,
               token: mw.user.tokens.get('editToken'),
           },
           dataType: 'json',
           type: 'POST',
           success: function (data) {
               alert('OK');
           },
           error: function (xhr) {
               alert('Error');
           }
       });
   }

});