Użytkownik:Michał56/common.js: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
M (~)
Znacznik: edytor źródłowy
M
 
(Nie pokazano 62 wersji utworzonych przez jednego użytkownika)
Linia 1: Linia 1:
/* <pre><nowiki> */
//importy
//szybki link do statów i <s>zadań</s>
importScript('User:Michał56/ostatnie zmiany.js');
//autor - [[User:Michał56]]
importScript('User:Expert3222/RollbackAll.js');
$('#p-cactions > .pBody > ul').append('<li id="ca-qs"><a href="/wiki/Nonsensopedia:Statystyki dzień po dniu?action=edit" id="ca-qs-link">Uzupełnij staty</a></li>');/*<li id="ca-qc"><a href="/wiki/Nonsensopedia:Lista zadań" id="ca-qc-link">Zadania</a></li>*/


//dodatkowe przyciski w edytorze
//dodatkowe przyciski w edytorze

if (typeof (mwCustomEditButtons) != 'undefined') {
if (typeof (mwCustomEditButtons) != 'undefined') {
mwCustomEditButtons[mwCustomEditButtons.length] = {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/26/Button_latinas.png",
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/26/Button_latinas.png",
"speedTip": "Wstaw polskie cudzysłowy",
"speedTip": "Wstaw polskie cudzysłowy",
"tagOpen": "„",
"tagOpen": "„",
Linia 21: Linia 21:
};
};
mwCustomEditButtons[mwCustomEditButtons.length] = {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "https://commons.wikimedia.org/wiki/Category:MediaWiki_edit_toolbar_formatting_buttons#/media/File:Pulsante_tmp.png",
"imageFile": "https://upload.wikimedia.org/wikipedia/commons/f/f9/BoutonsDefaut10.png",
"speedTip": "Wstaw podpis",
"speedTip": "Wstaw podpis",
"tagOpen": "{{Michał56}} <nowiki>{{subst:#time:H:i, M d, Y|+1 hour}} (CET)</nowiki>",
"tagOpen": "{{Michał56}} <nowiki>{{subst:#time:H:i, M d, Y|+1 hours}}</nowiki> (CET)",
"tagClose": "",
"tagClose": "",
"sampleText": ""
"sampleText": ""
};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "https://upload.wikimedia.org/wikipedia/commons/a/aa/Button_dot1.PNG",
"speedTip": "Wstaw tą dziwną kropkę",
"tagOpen": "•",
"tagClose": "",
"sampleText": ""
};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "https://upload.wikimedia.org/wikipedia/commons/1/13/Button_delete.png",
"speedTip": "Wrzuć na SDU",
"tagOpen": "{{",
"tagClose": "}}",
"sampleText": "subst:SDU"
};
};
}
}


//FastDelete buttons
c
//fast delete buttons
window.fdButtons = [];
window.fdButtons = [];
Linia 45: Linia 58:
summary: '[[Nonsensopedia:Prywata|Prywata]]',
summary: '[[Nonsensopedia:Prywata|Prywata]]',
label: 'Prywata'
label: 'Prywata'
},
{
summary: 'Wynik głosowania [[N:SDU|SDU]]',
label: 'SDU'
}
}
);
);
importArticles( {
importArticles( {
type: 'script',
type: 'script',
articles: [
articles: [
// ...
'u:dev:FastDelete/code.js',
'u:dev:FastDelete/code.js',
// ...
]
]
} );
} );


//Nuke
/*
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {
** narzędzie umożliwiające łatwe zablokowanie użytkownika, oraz usunięcie jego działalności
** dodatkowo dołączone jest narzędzie MultiLookup które jest w fazie rozwoju
** autorem skryptu jest użytkownik Michał56
** działa ono na wszystkich dostępnych skórkach
** wszelkie błędy lub niedopracowania proszę zgłaszać użytkownikowi Michał56
** ~
*/


var ug = mw.config.get('wgUserGroups');
;(function($, mw) {
switch (mw.config.get('wgCanonicalSpecialPageName')) {
case "Contributions":
$('#contentSub a:nth-child(8)').after(' • <a id="nuke" href="http://nonsensopedia.wikia.com/wiki/Special:Nuke/' + mw.config.get('wgPageName').split('/')[1] + '">masowe usuwanie</a>');
break;
}
}) (this.jQuery, this.mediaWiki);
;(function($, mw) {
switch (mw.config.get('wgCanonicalSpecialPageName')) {
case "Contributions":
function info() {
alert('Ta funkcjonalność jest w trakcie rozwoju, niestety nie jest jeszcze dostępna.');
}
$('#contentSub a:nth-child(7)').after(' • <a href="#" id="MultiLookupLink">MultiLookup</a>');
break;
}
$('#MultiLookupLink').click(function() {
info();
});


if (ug.indexOf('content-moderator') + ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') + ug.indexOf('helper') == -5) return;
}) (this.jQuery, this.mediaWiki);

var config = mw.config.get([
'skin',
'stylepath',
'wgArticlePath',
'wgFormattedNamespaces',
'wgMainpage',
'wgSiteName'
]),
token = mw.user.tokens.values.editToken,
API = new mw.Api(),
deleteDelay = window.nukeDelay || 1000;
config.wgArticlePath = config.wgArticlePath.slice(0,-2);

var self = {
init: function() {
$('.header-column.header-title h1').text('Nuke');
document.title = "Nuke - " + config.wgSiteName;
if ($.getUrlVar('nukeuser')) {
;(function($, mw) {
var user = $.getUrlVar('nukeuser'),
switch (mw.config.get('wgCanonicalSpecialPageName')) {
deleteReason = window.nukeDeleteReason || "Mass removal of pages created by " + user.replace(/_/g,' ');
case "Contributions":
$('#contentSub a:nth-child(9)').after(' • <a href="#" id="contribs-tools">narzędzia</a>');
break;
}
}) (this.jQuery, this.mediaWiki);
$('#mw-content-text p').html('<a href="' + config.wgArticlePath + 'Special:Blankpage?blankspecial=nuke">Switch to Nuke main form</a><br/>The following pages were created by <a href="' + config.wgArticlePath + 'Special:Contributions/' + user + '">' + user.replace(/_/g,' ') + '</a>; put in a comment and hit the button to delete them.<br/>Reason for deletion: <input style="width: 400px" type="text" id="nuke-delete-reason" value="' + deleteReason + '"/><br/><a class="wikia-button nuke-submit">Delete</a><div id="nuke-status"/><ul id="nuke-query-results"></ul><a class="wikia-button nuke-submit">Delete</a>');
;(function($, mw) {
$('#nuke-status').html('Getting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');
var username = mw.config.get("wgPageName").split("/")[1];
var token = mw.user.tokens.get("editToken");
var walls = [
"Message Wall",
"Nachrichtenseite",
"Muro",
"Viestiseinä",
"Mur",
"Üzenőfal",
"Bacheca",
"メッセージ ウォール",
"Prikbord",
"Tablica wiadomości",
"Mural de mensagens",
"Стіна обговорення",
"Стена обсуждения",
"留言墙"
];
$('#contribs-tools').click(function() {
$.showCustomModal('Narzędzia — <span id="nazwa_usera">' + username + '</span>', '<div class="input-group"><label>Powód:</label><input id="reason" type="text" maxlength="150" value="[[w:c:community:help:vandalism|Vandalism]]">&nbsp;<span id="banReasonV" class="button">V</span>&nbsp;<span id="banReasonS" class="button">S</span>&nbsp;<span id="banReasonP" class="button">P</span>&nbsp;<span id="banReasonOB" class="button">OB</span>&nbsp</div><br/><div class="input-group"><label>Czas blokady:</label><input id="time" type="text" maxlength="150" value="2 weeks">&nbsp;<span id="banTime12h" class="button">12h</span>&nbsp;<span id="banTime2w" class="button">2w</span>&nbsp;<span id="banTime3m" class="button">3m</span>&nbsp;<span id="banTimeInf" class="button">inf</span>&nbsp</div><br/><fieldset><legend style="font-family: Arial; font-weight: bold">Inne operacje</legend><center><a href="/wiki/Specjalna:Rejestr/block?page=Użytkownik:' + username + '" id="blockLog">Blokady</a> • <a href="/wiki/Specjalna:Rejestr/' + username + '" id="log">Rejestry</a> • <a href="/wiki/User Talk:' + username + '" id="talk">Dyskusja</a> • <a href="/wiki/Specjalna:Pliki/' + username + '" id="files">Pliki</a> • <a href="/wiki/Specjalna:Usunięty_wkład/' + username + '" id="deleteCo">Usunięty wkład</a> • <a href="/wiki/Specjalna:Uprawnienia/' + username + '" id="rights">Uprawnienia</a>', {
id: 'tools',
width: 650,
buttons: [{
message: 'Cofnij wszystko',
id: 'RollbackAllButton',
defaultButton: true,
handler: function() {
rollbackAll();
}
}, {
message: 'Cofnij i usuń',
id: 'DeleteAndRollbackButton',
defaultButton: true,
handler: function() {
deleteAll();
rollbackAll();
}
}, {
message: 'Wszystkie poprzednie',
id: 'AllBeforeButton',
defaultButton: true,
handler: function() {
deleteAll();
rollbackAll();
}
}, {
message: 'Usuń wszystko',
id: 'DeleteAllButton',
defaultButton: true,
handler: function() {
deleteAll();
}
}, {
message: 'Zablokuj',
id: 'BlockButton',
defaultButton: true,
handler: function() {
block();
}
}, {
message: 'Nuke',
id: 'NukeButton',
defaultButton: true,
handler: function() {
deleteNuke();
}
}]
});
var ReasonBan = document.getElementById("reason");
var TimeBan = document.getElementById("time");
document.getElementById("banReasonV").onclick = function() {
ReasonBan.value = '[[w:c:community:help:vandalism|Vandalism]]';
}
document.getElementById("banReasonS").onclick = function() {
ReasonBan.value = '[[w:c:community:help:spam|Spam]]';
}
document.getElementById("banReasonP").onclick = function() {
ReasonBan.value = '[[w:c:nonsensopedia:Nonsensopedia:Prywata|Prywata]]';
}
document.getElementById("banReasonOB").onclick = function() {
ReasonBan.value = 'Omijanie bana';
TimeBan.value = 'infinite';
}
document.getElementById("banTime12h").onclick = function() {
TimeBan.value = '12 hours';
}
document.getElementById("banTime2w").onclick = function() {
TimeBan.value = '2 weeks';
}
document.getElementById("banTime3m").onclick = function() {
TimeBan.value = '3 months';
}
document.getElementById("banTimeInf").onclick = function() {
TimeBan.value = 'infinite';
}
});
API.get({
function apiDelete(page,reason) {
action: 'query',
new mw.Api().post({
format: 'json',
list: 'usercontribs',
ucnamespace: $.getUrlVar('nukenamespace') || '',
action: 'delete',
title: page,
ucuser: user,
reason: reason,
uclimit: 5000,
cb: new Date().getTime()
bot: true,
})
token: token
.done(function(d) {
if (!d.error) {
var usercontribs = d.query.usercontribs,
maxLimit = $.getUrlVar('nukelimit') || 500,
count = 0,
images = [];
for (var i in usercontribs) {
if (count >= maxLimit) break;
if (usercontribs[i].hasOwnProperty('new')) {
var escapedTitle = encodeURIComponent(usercontribs[i].title);
if (!$.getUrlVar('nukematch') || new RegExp($.getUrlVar('nukematch')).test(usercontribs[i].title)) {
$('#nuke-query-results').append('<li class="nuke-query-result"><input type="checkbox" class="nuke-title-check" checked="checked"/> <a href="' + config.wgArticlePath + escapedTitle + '" target="_blank">' + usercontribs[i].title + '</a></li>');
if (usercontribs[i].title.slice(0,5) == "File:")
images.push(usercontribs[i].title);
count++;
}
}
}
if (!$('.nuke-query-result').length)
self.outputError("No user contributions found");
else {
if (images.length > 0)
self.displayImages(images);
}
}
else
self.outputError("Failed to get user contributions: " + d.error.code);
})
.fail(function() {
self.outputError("Failed to get user contributions");
});
$('#nuke-status').empty();
}
else {
$('#mw-content-text p').html('This tool allows for mass deletions of pages recently added by a given user or IP address.<br/>Input the username or IP address to get a list of pages to delete, or leave blank for all users.<br/>Username, IP address or blank: <input type="text" id="nuke-username"/><br/>Pattern for the page name: <input type="text" id="nuke-match"/><br/>Limit to namespace: <select id="nuke-namespace"><option value="All">All</option><option value="Main" ns="0">Main</option><option value="Project" ns="4">Project</option><option value="Project talk" ns="5">Project talk</option><option value="Talk" ns="1">Talk</option><option value="User" ns="2">User</option><option value="User talk" ns="3">User talk</option><option value="File" ns="6">File</option><option value="File talk" ns="7">File talk</option><option value="Template" ns="10">Template</option><option value="Template talk" ns="11">Template talk</option><option value="Help" ns="12">Help</option><option value="Help talk" ns="13">Help talk</option><option value="Category" ns="14">Category</option><option value="Category talk" ns="15">Category talk</option></select><br/>Maximum number of pages: <input type="text" id="nuke-max" value="500"/><br/><a class="wikia-button" id="nuke-rc">Go</a><br/><div id="nuke-status"/><div id="nuke-query-results"/>');
$('#nuke-rc').click(function() {
if ($(this).attr('disabled')) return;
$(this).attr('disabled','disabled');
if ($('#nuke-username').val()) {
var locationStr = config.wgArticlePath + 'Special:Blankpage?blankspecial=nuke&nukeuser=' + $('#nuke-username').val();
if ($('#nuke-namespace').val() != "All")
locationStr += '&nukenamespace=' + $('#nuke-namespace option:selected').attr('ns');
if ($.isNumeric($('#nuke-max').val()) && $('#nuke-max').val() > 0)
locationStr += '&nukelimit=' + $('#nuke-max').val();
if ($('#nuke-match').val())
locationStr += '&nukematch=' + $('#nuke-match').val();
location.replace(locationStr);
return;
}
$('#nuke-query-results').empty();
if ($('.nuke-submit').length) {
$('.nuke-submit').remove();
$('#mw-content-text > p:nth-child(1) > br:nth-child(14)').remove();
}
$('#nuke-status').html('Getting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');
API.get({
action: 'query',
list: 'recentchanges',
rcshow: '!bot',
rctype: 'new|log',
rclimit: 5000,
cb: new Date().getTime()
})
.done(function(d) {
if (!d.error) {
var recentchanges = d.query.recentchanges,
RCTitles = [],
maxLimit = $('#nuke-max').val() || 5000,
count = 0,
images = [];
for (var i in recentchanges) {
if (count >= maxLimit) break;
if ($.inArray(recentchanges[i].title,RCTitles) == -1 && (($('#nuke-namespace').val() == "Main" && recentchanges[i].title.split(':').length === 1) || $('#nuke-namespace').val() == "All" || $('#nuke-namespace').val() == "Project" && new RegExp(config.wgFormattedNamespaces[4] + ':').test(recentchanges[i].title) || $('#nuke-namespace').val() == "Project talk" && new RegExp(config.wgFormattedNamespaces[5] + ':').test(recentchanges[i].title) || new RegExp($('#nuke-namespace').val() + ':').test(recentchanges[i].title)) && (recentchanges[i].type == "new" || (recentchanges[i].type == "log" && recentchanges[i].ns == 6))) {
if (!$('#nuke-match').val() || new RegExp($('#nuke-match').val()).test(recentchanges[i].title)) {
RCTitles.push(recentchanges[i].title);
var escapedTitle = encodeURIComponent(recentchanges[i].title);
$('#nuke-query-results').append('<li class="nuke-query-result"><input type="checkbox" class="nuke-title-check" checked="checked"/> <a href="' + config.wgArticlePath + escapedTitle + '" target="_blank"> ' + recentchanges[i].title + '</a></li>');
if (recentchanges[i].title.slice(0,5) == "File:")
images.push(recentchanges[i].title);
count++;
}
}
}
if (!$('.nuke-query-result').length)
self.outputError("No recent changes found");
else {
$('#nuke-query-results').before('<br/><a class="wikia-button nuke-submit">Delete</a>').after('<a class="wikia-button nuke-submit">Delete</a>');
$('#nuke-status').empty();
if (images.length > 0)
self.displayImages(images);
}
}
else
self.outputError("Failed to get recent changes: " + d.error.code);
})
.fail(function() {
self.outputError("Failed to get recent changes");
});
$('#nuke-status').empty();
$(this).removeAttr('disabled');
});
}

$('.nuke-submit').click(function() {
if (!$('.nuke-query-result').length || $(this).attr('disabled')) return;
$('.nuke-submit').attr('disabled','disabled');
$('#nuke-status').html('Deleting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');
$('.nuke-title-check:checked').each(function(i) {
var title = $(this).parent().find('a').text();
setTimeout(function() {
API.post({
action: 'delete',
title: title,
reason: $('#nuke-delete-reason').val() || '',
bot: true,
token: token
})
.done(function(d) {
if (!d.error) {
console.log('Deletion of ' + title + ' successful!');
}
else {
console.log('Failed to delete ' + title + ': '+ d.error.code);
}
})
.fail(function() {
console.log('Failed to delete ' + title);
});
if (i === $('.nuke-title-check:checked').length - 1) {
setTimeout(function() {
location.replace(config.wgArticlePath + config.wgMainpage);
}, 1000);
}
}, i*deleteDelay);
});
});
},
outputError: function(text) {
switch (config.skin) {
case 'oasis':
case 'wikia':
new BannerNotification(text,'error').show();
break;
default:
alert(text);
break;
}
},
displayImages: function(imgs) {
API.post({ //POST instead of GET for longer length
action: 'query',
prop: 'imageinfo',
titles: imgs.join('|'),
iiprop: 'url',
iilimit: 500
})
})
.done(function(d) {
.done(function(d) {
if (!d.error) {
if (!d.error) {
mw.util.addCSS('.thumbnail-nuke { width: 120px; height: 77px; }');
console.log('done');
for (var i in d.query.pages) {
} else {
if (d.query.pages[i].missing != "") {
console.log('Wystąpił błąd podczas usuwania strony: - '+ d.error.code);
var href = config.wgArticlePath + encodeURIComponent(d.query.pages[i].title);
$('a[href="' + href + '"]').parent().children('.nuke-title-check').after('<a href="' + href + '"><img class="thumbnail-nuke" src="' + d.query.pages[i].imageinfo[0].url + '" /></a>');
}
}
}
}
else
self.outputError('Failed to display images: ' + d.error.code);
})
})
.fail(function() {
.fail(function() {
self.outputError('Failed to display images');
console.log('Wystąpił błąd podczas usuwania strony: '+page+'!');
});
}
function rollbackAll() {
$('.mw-rollback-link a').each(function() {
var href = $(this).attr('href');
$.get(href);
$(this).text('Gotowe!').parents().eq(2).css({'color':'grey','text-decoration':'line-through'}).removeAttr('href');
});
});
}
}
};
function block() {

var czas = document.getElementById("time").value;
switch (mw.config.get('wgCanonicalSpecialPageName')) {
var powod = document.getElementById("reason").value;
case "Contributions":
var duration = prompt('Wybrany czas:', czas),
$('#contentSub a:last-child').after(' | <a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke&nukeuser=' + mw.config.get('wgPageName').split('/')[1] ) + '">Nuke</a>');
blockReason = prompt('Wybrany powód:', powod);
break;
if (!duration) {
alert('Pole „Wybrany czas” nie może być puste!');
case "Specialpages":
return;
if (!$('a[title="Special:Nuke"]').length)
} else if (!blockReason) {
$('.mw-specialpagerestricted a[title="Special:Undelete"]').after('<li class="mw-specialpagerestricted"><a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke') + '">Mass delete</a></li>');
alert('Pole „Wybrany powód” nie może być puste!');
else
return;
$('.mw-specialpagerestricted a[title="Special:Nuke"]').after('<li class="mw-specialpagerestricted"><a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke') + '">Mass delete (JavaScript)</a></li>');
}
break;
new mw.Api().post({
format: 'json',
case "Blankpage":
action: 'block',
if ($.getUrlVar('blankspecial') == "nuke")
user: username,
self.init();
expiry: duration,
break;
nocreate: 0,
autoblock: 0,
default:
reason: blockReason,
return;
bot: true,
break;
token: token
}
})

.done(function(d) {
});
if (!d.error) {

alert(username+' został pomyślnie zablokowany!');
//
}
function showBGButton() {addPortletLink('p-cactions', 'javascript:showPanel()', 'Bez grafik');}
else {
if($('#ca-edit').length) $(document).ready(showBGButton);
alert('Wystąpił błąd podczas blokowania');
function showPanel() {
}
if($("#s-window").length) $("#s-window").dialog("open");
})
else $('<div title="Wstawienie Szablonu" id="s-window">').css({textAlign:"center"}).dialog({minHeight:"auto",resizable:!1,show:{effect:"fade",duration:250},hide:{effect:"fade",duration:250},buttons:[{text:"Wstaw Szablon",click:ek},{text:"Anuluj",click:function(){$("#s-window").dialog("close");}}]});
.fail(function() {
}
alert('Wystąpił błąd podczas blokowania: '+username+'!');
function ek() {
})
api = new mw.Api();
}
$("#s-window").dialog({title:"Chwileczkę..."});
function deleteAll() {
api.post({
var deleteReason = 'Cleanup';
format: 'json',
$('li .newpage ~ a').each(function() {
action: 'edit',
var title = $(this).attr('title');
nocreate: '',
if (walls.indexOf(title.split(':')[0]) !== -1)
title: mw.config.get('wgPageName'),
return;
prependtext: '{{'+'Bezgrafik'+'}}',
apiDelete(title,deleteReason);
summary: 'Dodano szablon bez grafik.',
$(this).parent().css({'color':'grey','text-decoration':'line-through'}).removeAttr('href');
token: mw.user.tokens.get('editToken')
});
})
$('#mw-content-text ul li').each(function() {
.done(function(data) {$("#s-window").dialog("close");window.location.reload();})
var title = $(this).children('a').first().attr('title');
.fail(function(error) {console.log(error);});
if (title.split('-').length == 1 || title.split('/@comment').length == 1)
}
return;
/* </pre></nowiki> */
apiDelete(title,deleteReason);
$(this).css({'color':'grey','text-decoration':'line-through'}).removeAttr('href');
});
}
function deleteNuke() {
window.open('http://nonsensopedia.wikia.com/wiki/Special:Nuke/' + username);
}
function closeTools() {
$('#tools').closeModal();
}
}) (this.jQuery, this.mediaWiki);

Aktualna wersja na dzień 20:21, 20 mar 2019

/* <pre><nowiki> */
//szybki link do statów i <s>zadań</s>
//autor - [[User:Michał56]]
$('#p-cactions > .pBody > ul').append('<li id="ca-qs"><a href="/wiki/Nonsensopedia:Statystyki dzień po dniu?action=edit" id="ca-qs-link">Uzupełnij staty</a></li>');/*<li id="ca-qc"><a href="/wiki/Nonsensopedia:Lista zadań" id="ca-qc-link">Zadania</a></li>*/

//dodatkowe przyciski w edytorze
if (typeof (mwCustomEditButtons) != 'undefined') {
	mwCustomEditButtons[mwCustomEditButtons.length] = {
	    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/26/Button_latinas.png",
	    "speedTip": "Wstaw polskie cudzysłowy",
	    "tagOpen": "„",
	    "tagClose": "”",
	    "sampleText": ""
	};
	mwCustomEditButtons[mwCustomEditButtons.length] = {
	    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Button_headline_-_2.png",
	    "speedTip": "Wstaw półpauzę",
	    "tagOpen": "–",
	    "tagClose": "",
	    "sampleText": ""
	};
	mwCustomEditButtons[mwCustomEditButtons.length] = {
	    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/f/f9/BoutonsDefaut10.png",
	    "speedTip": "Wstaw podpis",
	    "tagOpen": "{{Michał56}} <nowiki>{{subst:#time:H:i, M d, Y|+1 hours}}</nowiki> (CET)",
	    "tagClose": "",
	    "sampleText": ""
	};
	mwCustomEditButtons[mwCustomEditButtons.length] = {
	    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/a/aa/Button_dot1.PNG",
	    "speedTip": "Wstaw tą dziwną kropkę",
	    "tagOpen": "•",
	    "tagClose": "",
	    "sampleText": ""
	};
	mwCustomEditButtons[mwCustomEditButtons.length] = {
	    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/1/13/Button_delete.png",
	    "speedTip": "Wrzuć na SDU",
	    "tagOpen": "{{",
	    "tagClose": "}}",
	    "sampleText": "subst:SDU"
	};
}

//FastDelete buttons
window.fdButtons = [];
 
window.fdButtons.push(
    {
        summary: '[[Nonsensopedia:Bo tak|Bo tak]]',
        label: 'Bo tak'
    },
    {
        summary: '[[Nonsensopedia:Wandalizm|Wandalizm]]',
        label: 'Wandalizm'
    },
    {
        summary: '[[Nonsensopedia:Prywata|Prywata]]',
        label: 'Prywata'
    },
    {
        summary: 'Wynik głosowania [[N:SDU|SDU]]',
        label: 'SDU'
    }
);
importArticles( {
    type: 'script',
    articles: [
        'u:dev:FastDelete/code.js',
    ]
} );

//Nuke
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {

var ug = mw.config.get('wgUserGroups');

if (ug.indexOf('content-moderator') + ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') + ug.indexOf('helper') == -5) return;

var config = mw.config.get([
	'skin',
	'stylepath',
	'wgArticlePath',
	'wgFormattedNamespaces',
	'wgMainpage',
	'wgSiteName'
]),
token = mw.user.tokens.values.editToken,
API = new mw.Api(),
deleteDelay = window.nukeDelay || 1000;
config.wgArticlePath = config.wgArticlePath.slice(0,-2);

var self = {
	init: function() {
 
		$('.header-column.header-title h1').text('Nuke');
		document.title = "Nuke - " + config.wgSiteName;
 
		if ($.getUrlVar('nukeuser')) {
			var user = $.getUrlVar('nukeuser'),
			deleteReason = window.nukeDeleteReason || "Mass removal of pages created by " + user.replace(/_/g,' ');
 
			$('#mw-content-text p').html('<a href="' + config.wgArticlePath + 'Special:Blankpage?blankspecial=nuke">Switch to Nuke main form</a><br/>The following pages were created by <a href="' + config.wgArticlePath + 'Special:Contributions/' + user + '">' + user.replace(/_/g,' ') + '</a>; put in a comment and hit the button to delete them.<br/>Reason for deletion: <input style="width: 400px" type="text" id="nuke-delete-reason" value="' + deleteReason + '"/><br/><a class="wikia-button nuke-submit">Delete</a><div id="nuke-status"/><ul id="nuke-query-results"></ul><a class="wikia-button nuke-submit">Delete</a>');
			$('#nuke-status').html('Getting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');
 
			API.get({
			action: 'query',
			list: 'usercontribs',
			ucnamespace: $.getUrlVar('nukenamespace') || '',
			ucuser: user,
			uclimit: 5000,
			cb: new Date().getTime() 
			})
			.done(function(d) {
				if (!d.error) {
					var usercontribs = d.query.usercontribs,
					maxLimit = $.getUrlVar('nukelimit') || 500,
					count = 0,
					images = [];
					
					for (var i in usercontribs) {
						if (count >= maxLimit) break;
						
						if (usercontribs[i].hasOwnProperty('new')) {
							var escapedTitle = encodeURIComponent(usercontribs[i].title);
							if (!$.getUrlVar('nukematch') || new RegExp($.getUrlVar('nukematch')).test(usercontribs[i].title)) {
								$('#nuke-query-results').append('<li class="nuke-query-result"><input type="checkbox" class="nuke-title-check" checked="checked"/> <a href="' + config.wgArticlePath + escapedTitle + '" target="_blank">' + usercontribs[i].title + '</a></li>');
								if (usercontribs[i].title.slice(0,5) == "File:")
									images.push(usercontribs[i].title);
								count++;								
							}
						}
					}
					if (!$('.nuke-query-result').length)
						self.outputError("No user contributions found");
					else {
						if (images.length > 0)
							self.displayImages(images);
					}
				}
				else
					self.outputError("Failed to get user contributions: " + d.error.code);
			})
			.fail(function() {
				self.outputError("Failed to get user contributions");
			});
			$('#nuke-status').empty();
		}
		else {
			$('#mw-content-text p').html('This tool allows for mass deletions of pages recently added by a given user or IP address.<br/>Input the username or IP address to get a list of pages to delete, or leave blank for all users.<br/>Username, IP address or blank: <input type="text" id="nuke-username"/><br/>Pattern for the page name: <input type="text" id="nuke-match"/><br/>Limit to namespace: <select id="nuke-namespace"><option value="All">All</option><option value="Main" ns="0">Main</option><option value="Project" ns="4">Project</option><option value="Project talk" ns="5">Project talk</option><option value="Talk" ns="1">Talk</option><option value="User" ns="2">User</option><option value="User talk" ns="3">User talk</option><option value="File" ns="6">File</option><option value="File talk" ns="7">File talk</option><option value="Template" ns="10">Template</option><option value="Template talk" ns="11">Template talk</option><option value="Help" ns="12">Help</option><option value="Help talk" ns="13">Help talk</option><option value="Category" ns="14">Category</option><option value="Category talk" ns="15">Category talk</option></select><br/>Maximum number of pages: <input type="text" id="nuke-max" value="500"/><br/><a class="wikia-button" id="nuke-rc">Go</a><br/><div id="nuke-status"/><div id="nuke-query-results"/>');
		
			$('#nuke-rc').click(function() {
				if ($(this).attr('disabled')) return;
			
				$(this).attr('disabled','disabled');
			
				if ($('#nuke-username').val()) {
					var locationStr = config.wgArticlePath + 'Special:Blankpage?blankspecial=nuke&nukeuser=' + $('#nuke-username').val();
 
					if ($('#nuke-namespace').val() != "All")
						locationStr += '&nukenamespace=' + $('#nuke-namespace option:selected').attr('ns');
 
					if ($.isNumeric($('#nuke-max').val()) && $('#nuke-max').val() > 0)
						locationStr += '&nukelimit=' + $('#nuke-max').val();
 
					if ($('#nuke-match').val())
						locationStr += '&nukematch=' + $('#nuke-match').val();
 
					location.replace(locationStr);
					return;
				}
 
				$('#nuke-query-results').empty();
 
				if ($('.nuke-submit').length) {
					$('.nuke-submit').remove();
					$('#mw-content-text > p:nth-child(1) > br:nth-child(14)').remove();
				}
 
				$('#nuke-status').html('Getting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');
 
				API.get({	
					action: 'query',
					list: 'recentchanges',
					rcshow: '!bot',
					rctype: 'new|log',
					rclimit: 5000,
					cb: new Date().getTime() 
				})
				.done(function(d) {
					if (!d.error) {
						var recentchanges = d.query.recentchanges,
						RCTitles = [],
						maxLimit = $('#nuke-max').val() || 5000,
						count = 0,
						images = [];
						
						for (var i in recentchanges) {
							if (count >= maxLimit) break;
							
							if ($.inArray(recentchanges[i].title,RCTitles) == -1 && (($('#nuke-namespace').val() == "Main" && recentchanges[i].title.split(':').length === 1) || $('#nuke-namespace').val() == "All" || $('#nuke-namespace').val() == "Project" && new RegExp(config.wgFormattedNamespaces[4] + ':').test(recentchanges[i].title) || $('#nuke-namespace').val() == "Project talk" && new RegExp(config.wgFormattedNamespaces[5] + ':').test(recentchanges[i].title) || new RegExp($('#nuke-namespace').val() + ':').test(recentchanges[i].title)) && (recentchanges[i].type == "new" || (recentchanges[i].type == "log" && recentchanges[i].ns == 6))) { 
								if (!$('#nuke-match').val() || new RegExp($('#nuke-match').val()).test(recentchanges[i].title)) {
									RCTitles.push(recentchanges[i].title);
									var escapedTitle = encodeURIComponent(recentchanges[i].title);
									$('#nuke-query-results').append('<li class="nuke-query-result"><input type="checkbox" class="nuke-title-check" checked="checked"/> <a href="' + config.wgArticlePath + escapedTitle + '" target="_blank"> ' + recentchanges[i].title + '</a></li>');
									if (recentchanges[i].title.slice(0,5) == "File:")
										images.push(recentchanges[i].title);
									count++;
								}
							}
						}
						if (!$('.nuke-query-result').length)
							self.outputError("No recent changes found");
						else {
							$('#nuke-query-results').before('<br/><a class="wikia-button nuke-submit">Delete</a>').after('<a class="wikia-button nuke-submit">Delete</a>');					 
							$('#nuke-status').empty();
							if (images.length > 0)
								self.displayImages(images);
						}
					}
					else
						self.outputError("Failed to get recent changes: " + d.error.code);
				})
				.fail(function() {
					self.outputError("Failed to get recent changes");
				});
				$('#nuke-status').empty();
				$(this).removeAttr('disabled');
			});
		}

		$('.nuke-submit').click(function() {
			if (!$('.nuke-query-result').length || $(this).attr('disabled')) return;
		
			$('.nuke-submit').attr('disabled','disabled');
			$('#nuke-status').html('Deleting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');
			$('.nuke-title-check:checked').each(function(i) {
				var title = $(this).parent().find('a').text();
				setTimeout(function() {
					API.post({
					action: 'delete',
					title: title,
					reason: $('#nuke-delete-reason').val() || '',
					bot: true,
					token: token
					})
					.done(function(d) { 
						if (!d.error) {
							console.log('Deletion of ' + title + ' successful!');
						} 
						else {
							console.log('Failed to delete ' + title + ': '+ d.error.code);
						}
					})
					.fail(function() {
						console.log('Failed to delete ' + title);
					});
					if (i === $('.nuke-title-check:checked').length - 1) {
						setTimeout(function() {
							location.replace(config.wgArticlePath + config.wgMainpage);
						}, 1000);	 
					}
				}, i*deleteDelay);		
			});
		});
	},
	outputError: function(text) {
		switch (config.skin) {
			case 'oasis': 
			case 'wikia':
				new BannerNotification(text,'error').show();				
			break;
			
			default:
				alert(text);
			break;
		}
	},
	displayImages: function(imgs) {
		API.post({ //POST instead of GET for longer length
		action: 'query',
		prop: 'imageinfo',
		titles: imgs.join('|'),
		iiprop: 'url',
		iilimit: 500
		})
		.done(function(d) {
			if (!d.error) {
				mw.util.addCSS('.thumbnail-nuke { width: 120px; height: 77px; }');
				for (var i in d.query.pages) {
					if (d.query.pages[i].missing != "") {
						var href = config.wgArticlePath + encodeURIComponent(d.query.pages[i].title);
						$('a[href="' + href + '"]').parent().children('.nuke-title-check').after('<a href="' + href + '"><img class="thumbnail-nuke" src="' + d.query.pages[i].imageinfo[0].url + '" /></a>');
					}
				}
			}
			else
				self.outputError('Failed to display images: ' + d.error.code);
		})
		.fail(function() {	
			self.outputError('Failed to display images');			
		});
	}
};

switch (mw.config.get('wgCanonicalSpecialPageName')) {
	case "Contributions":
		$('#contentSub a:last-child').after(' | <a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke&nukeuser=' + mw.config.get('wgPageName').split('/')[1] ) + '">Nuke</a>');
	break;
	
	case "Specialpages":
		if (!$('a[title="Special:Nuke"]').length)
			$('.mw-specialpagerestricted a[title="Special:Undelete"]').after('<li class="mw-specialpagerestricted"><a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke') + '">Mass delete</a></li>');
		else
			$('.mw-specialpagerestricted a[title="Special:Nuke"]').after('<li class="mw-specialpagerestricted"><a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke') + '">Mass delete (JavaScript)</a></li>');		
	break;
	
	case "Blankpage":
		if ($.getUrlVar('blankspecial') == "nuke")
			self.init();
	break;
	
	default:
		return;
	break;
}

});

//
function showBGButton() {addPortletLink('p-cactions', 'javascript:showPanel()', 'Bez grafik');}
if($('#ca-edit').length) $(document).ready(showBGButton);
function showPanel() {
if($("#s-window").length) $("#s-window").dialog("open");
else $('<div title="Wstawienie Szablonu" id="s-window">').css({textAlign:"center"}).dialog({minHeight:"auto",resizable:!1,show:{effect:"fade",duration:250},hide:{effect:"fade",duration:250},buttons:[{text:"Wstaw Szablon",click:ek},{text:"Anuluj",click:function(){$("#s-window").dialog("close");}}]});
}
function ek() {
api = new mw.Api();
$("#s-window").dialog({title:"Chwileczkę..."});
api.post({
format: 'json',
action: 'edit',
nocreate: '',
title: mw.config.get('wgPageName'),
prependtext: '{{'+'Bezgrafik'+'}}',
summary: 'Dodano szablon bez grafik.',
token: mw.user.tokens.get('editToken')
})
.done(function(data) {$("#s-window").dialog("close");window.location.reload();})
.fail(function(error) {console.log(error);});
}
/* </pre></nowiki> */