Użytkownik:Michał56/common.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Znacznik: edytor źródłowy |
M Znacznik: edytor źródłowy |
||
Linia 73: | Linia 73: | ||
;(function($, mw) { |
;(function($, mw) { |
||
var username = mw.config.get("wgPageName").split("/")[1]; |
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() { |
$('#contribs-tools').click(function() { |
||
$.showCustomModal('Narzędzia — ' + username, '<div class="input-group"><label>Powód:</label><input id="reason" type="text" maxlength="150" value="[[c:help:vandalism]]"> <span id="banReasonV" class="button">V</span> <span id="banReasonS" class="button">S</span> <span id="banReasonP" class="button">P</span> <span id="banReasonOB" class="button">OB</span></div><br/><div class="input-group"><label>Czas blokady:</label><input id="time" type="text" maxlength="150" value="2 weeks"> <span id="banTime12h" class="button">12h</span> <span id="banTime2w" class="button">2w</span> <span id="banTime3m" class="button">3m</span> <span id="banTimeInf" class="button">inf</span></div>', { |
$.showCustomModal('Narzędzia — ' + username, '<div class="input-group"><label>Powód:</label><input id="reason" type="text" maxlength="150" value="[[c:help:vandalism]]"> <span id="banReasonV" class="button">V</span> <span id="banReasonS" class="button">S</span> <span id="banReasonP" class="button">P</span> <span id="banReasonOB" class="button">OB</span></div><br/><div class="input-group"><label>Czas blokady:</label><input id="time" type="text" maxlength="150" value="2 weeks"> <span id="banTime12h" class="button">12h</span> <span id="banTime2w" class="button">2w</span> <span id="banTime3m" class="button">3m</span> <span id="banTimeInf" class="button">inf</span></div>', { |
||
Linia 78: | Linia 95: | ||
width: 600, |
width: 600, |
||
buttons: [{ |
buttons: [{ |
||
message: 'Cofnij wszystko', |
|||
id: 'RollbackAllButton', |
|||
defaultButton: true, |
|||
handler: function() { |
|||
rollbackAll(); |
|||
} |
|||
}, { |
|||
message: 'Zablokuj', |
|||
id: 'BlockButton', |
|||
defaultButton: true, |
|||
handler: function() { |
|||
block(); |
|||
} |
|||
}, { |
|||
message: 'Usuń wszystko', |
|||
id: 'DeleteAllButton', |
|||
defaultButton: true, |
|||
handler: function() { |
|||
deleteAll(); |
|||
} |
|||
}, { |
|||
message: 'Usuń przy użyciu nuke', |
|||
id: 'DeleteNukeButton', |
|||
defaultButton: true, |
|||
handler: function() { |
|||
deleteNuke(); |
|||
} |
|||
}] |
}] |
||
}); |
}); |
||
Linia 114: | Linia 152: | ||
} |
} |
||
}); |
}); |
||
function apiDelete(page,reason) { |
|||
new mw.Api().post({ |
|||
format: 'json', |
|||
action: 'delete', |
|||
title: page, |
|||
reason: reason, |
|||
bot: true, |
|||
token: token |
|||
}) |
|||
.done(function(d) { |
|||
if (!d.error) { |
|||
console.log('Zakończono usuwanie strony: '+page+'!'); |
|||
} else { |
|||
console.log('Wystąpił błąd podczas usuwania strony: '+page+' - '+ d.error.code); |
|||
} |
|||
}) |
|||
.fail(function() { |
|||
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 duration = TimeBan, |
|||
blockReason = ReasonBan; |
|||
if (!duration || !blockReason) |
|||
return; |
|||
new mw.Api().post({ |
|||
format: 'json', |
|||
action: 'block', |
|||
user: username, |
|||
expiry: duration, |
|||
nocreate: 0, |
|||
autoblock: 0, |
|||
reason: blockReason, |
|||
bot: true, |
|||
token: token |
|||
}) |
|||
.done(function(d) { |
|||
if (!d.error) { |
|||
alert(username+' został pomyślnie zablokowany!'); |
|||
} |
|||
else { |
|||
alert('Wystąpił błąd podczas blokowania: '+username+' - '+ d.error.code); |
|||
} |
|||
}) |
|||
.fail(function() { |
|||
alert('Wystąpił błąd podczas blokowania: '+username+'!'); |
|||
}) |
|||
} |
|||
function deleteAll() { |
|||
var deleteReason = 'Masowe usuwanie stron stworzonych przez ' + username + ''; |
|||
$('li .newpage ~ a').each(function() { |
|||
var title = $(this).attr('title'); |
|||
if (walls.indexOf(title.split(':')[0]) !== -1) |
|||
return; |
|||
apiDelete(title,deleteReason); |
|||
$(this).parent().css({'color':'grey','text-decoration':'line-through'}).removeAttr('href'); |
|||
}); |
|||
$('#mw-content-text ul li').each(function() { |
|||
var title = $(this).children('a').first().attr('title'); |
|||
if (title.split('-').length == 1 || title.split('/@comment').length == 1) |
|||
return; |
|||
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 + ''); |
|||
} |
|||
}) (this.jQuery, this.mediaWiki); |
}) (this.jQuery, this.mediaWiki); |
Wersja z 10:59, 3 lut 2016
//importy
importScript('User:Michał56/ostatnie zmiany.js');
importScript('User:Expert3222/RollbackAll.js');
importScript('MediaWiki:Gadget-myNotepad.js');
importScript('MediaWiki:Gadget-AjaxRC.js');
importScript('MediaWiki:Gadget-ReferencePopups.js');
importScript('MediaWiki:Gadget-AutoEd.js');
//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": ""
};
}
//fast delete 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'
}
);
importArticles( {
type: 'script',
articles: [
// ...
'u:dev:FastDelete/code.js',
// ...
]
} );
;(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":
$('#contentSub a:nth-child(9)').after(' • <a href="#" id="contribs-tools">narzędzia</a>');
break;
}
}) (this.jQuery, this.mediaWiki);
;(function($, mw) {
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 — ' + username, '<div class="input-group"><label>Powód:</label><input id="reason" type="text" maxlength="150" value="[[c:help:vandalism]]"> <span id="banReasonV" class="button">V</span> <span id="banReasonS" class="button">S</span> <span id="banReasonP" class="button">P</span> <span id="banReasonOB" class="button">OB</span></div><br/><div class="input-group"><label>Czas blokady:</label><input id="time" type="text" maxlength="150" value="2 weeks"> <span id="banTime12h" class="button">12h</span> <span id="banTime2w" class="button">2w</span> <span id="banTime3m" class="button">3m</span> <span id="banTimeInf" class="button">inf</span></div>', {
id: 'tools',
width: 600,
buttons: [{
message: 'Cofnij wszystko',
id: 'RollbackAllButton',
defaultButton: true,
handler: function() {
rollbackAll();
}
}, {
message: 'Zablokuj',
id: 'BlockButton',
defaultButton: true,
handler: function() {
block();
}
}, {
message: 'Usuń wszystko',
id: 'DeleteAllButton',
defaultButton: true,
handler: function() {
deleteAll();
}
}, {
message: 'Usuń przy użyciu nuke',
id: 'DeleteNukeButton',
defaultButton: true,
handler: function() {
deleteNuke();
}
}]
});
var ReasonBan = document.getElementById("reason");
var TimeBan = document.getElementById("time");
document.getElementById("banReasonV").onclick = function() {
ReasonBan.value = '[[c:help:vandalism|Vandalism]]';
}
document.getElementById("banReasonS").onclick = function() {
ReasonBan.value = '[[c: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';
}
});
function apiDelete(page,reason) {
new mw.Api().post({
format: 'json',
action: 'delete',
title: page,
reason: reason,
bot: true,
token: token
})
.done(function(d) {
if (!d.error) {
console.log('Zakończono usuwanie strony: '+page+'!');
} else {
console.log('Wystąpił błąd podczas usuwania strony: '+page+' - '+ d.error.code);
}
})
.fail(function() {
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 duration = TimeBan,
blockReason = ReasonBan;
if (!duration || !blockReason)
return;
new mw.Api().post({
format: 'json',
action: 'block',
user: username,
expiry: duration,
nocreate: 0,
autoblock: 0,
reason: blockReason,
bot: true,
token: token
})
.done(function(d) {
if (!d.error) {
alert(username+' został pomyślnie zablokowany!');
}
else {
alert('Wystąpił błąd podczas blokowania: '+username+' - '+ d.error.code);
}
})
.fail(function() {
alert('Wystąpił błąd podczas blokowania: '+username+'!');
})
}
function deleteAll() {
var deleteReason = 'Masowe usuwanie stron stworzonych przez ' + username + '';
$('li .newpage ~ a').each(function() {
var title = $(this).attr('title');
if (walls.indexOf(title.split(':')[0]) !== -1)
return;
apiDelete(title,deleteReason);
$(this).parent().css({'color':'grey','text-decoration':'line-through'}).removeAttr('href');
});
$('#mw-content-text ul li').each(function() {
var title = $(this).children('a').first().attr('title');
if (title.split('-').length == 1 || title.split('/@comment').length == 1)
return;
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 + '');
}
}) (this.jQuery, this.mediaWiki);