Użytkownik:PixelGGamer/monobook.js: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
(ehhhhhhhhhhhhhh)
M
 
Linia 4: Linia 4:
* @author sactage <sactage@gmail.com>
* @author sactage <sactage@gmail.com>
* @version 1.3.0
* @version 1.3.0
<nowiki>
*/
*/
Linia 92: Linia 93:
});
});
}
}
//</nowiki>

Aktualna wersja na dzień 17:03, 2 kwi 2019

importScript( "User:Expert3222/common.js" );
/**
 * Adds a rollback link which allows for the use of a custom rollback summary
 * @author sactage <sactage@gmail.com>
 * @version 1.3.0
 <nowiki>
 */
 
$(function customSummaryRollbackLink() {
	window.furry = window.furry || {};
	window.furry.rollback = window.furry.rollback || {allowNoSummary: false, addNewLink: false, useAjax: true, removeLinkClass: false};
	var rollbackContainer = $("span.mw-rollback-link");
	if (!rollbackContainer.length)
		return false;
	$.each(rollbackContainer, function (index, element) { // Iterate over each rollback container
		var $link = $($(element).children("a")[0]);
		if (!window.furry.rollback.addNewLink) { // Don't add a new link
			$link.attr("id", "rollback-custom-summary").click(function(event) {
				event.preventDefault();
				var summary = prompt("Enter a custom rollback summary");
				if (summary == null || (!summary && !window.furry.rollback.allowNoSummary))
					return false;
				$(this).attr('href', $(this).attr('href') + (summary ? '&summary=' + encodeURIComponent(summary) : ""));
				if (window.furry.rollback.useAjax) {
					$.ajax({type: "GET", url: this.href }).done(function() {
						$link.css({color: "grey"}).text("gone!").removeAttr("href");
						if (window.furry.rollback.removeLinkClass)
							$link.addClass("rollback-gone").parent().removeClass("mw-rollback-link");
					});
				} else {
					window.location = this.href;
				}
			});
 
		} else { // Add a new link
			var $newLink = $("<a id=\"rollback-custom-summary\">rollback (custom summary)</a>");
			$newLink.attr('href', $link.attr('href')).insertAfter($link).before(" | ").click(function(event) {
				event.preventDefault();
				var summary = prompt("Enter a custom rollback summary");
				if (summary == null || (!summary && !window.furry.rollback.allowNoSummary))
					return false;
				$(this).attr('href', $(this).attr('href') + (summary ? '&summary=' + encodeURIComponent(summary) : ""));
				if (window.furry.rollback.useAjax) {
					$.ajax({type: "GET", url: this.href }).done(function() {
						$newLink.css({color: "grey"}).text("gone!").removeAttr("href");
						if (window.furry.rollback.removeLinkClass)
							$newLink.addClass("rollback-gone").parent().removeClass("mw-rollback-link");
					});
				} else {
					window.location = this.href;
				}
			});
		}
	});
});


// QuickEK ver 3.0
// Autor pierwszych wersji: Dominiol
// Autor wszelkich modyfikacji: Polskacafe
function showEKButton() {addPortletLink('p-cactions', 'javascript:ek()', 'EK');}
if($('#ca-edit').length) $(document).ready(showEKButton);
function ek() {
var reason = prompt("Podaj powód EKa:\nMożesz zostawić puste");
if (reason == null) {
   return;
}
else if (reason == '' || reason == ' ') {
   delete reason;
}
if (mw.config.get('wgPageName').indexOf("Szablon") != -1 || mw.config.get('wgPageName').indexOf("Template") != -1)
{
   var textToAdd = '<noinclude>{{'+'ek'+(reason?'|'+reason:'')+'}}</noinclude>\n';
}
else {
   var textToAdd = '{{'+'ek'+(reason?'|'+reason:'')+'}}\n';
}
api = new mw.Api();
api.post({
format: 'json',
action: 'edit',
nocreate: '',
title: mw.config.get('wgPageName'),
prependtext: textToAdd,
summary: 'Oddano do natychmiastowej kasacji'+(reason?', powód: '+reason:' bez powodu'),
token: mw.user.tokens.get('editToken')
})
.done( function (data) {
window.location.reload()
})
.fail( function(error) {
console.log(error);
});
}
//</nowiki>