MediaWiki:Gadget-OtomatikKategoriDuzenleyici.js

Vikipedi, özgür ansiklopedi

Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.

{
"use strict";

const action = mw.config.get("wgAction");

const update = function (pageTitle) {
	const title = pageTitle;
	const icerik = "{{#invoke:Kategori|goster|2010}}";
	const ozet = "[[MediaWiki:Gadget-OtomatikKategoriDuzenleyici.js|deneme]]";

	return mw.loader.using("mediawiki.api", function () {
		return new mw.Api().get({
			action: "expandtemplates",
			title: title,
			text: template,
			prop: "wikitext",
		}).done(function (data) {
			var expanded = data.expandtemplates.wikitext;
			return new mw.Api().edit(title, function () {
				return {
					text: expanded,
					summary: summary,
				};
			}).done(function (data) {
				if (data.nochange) {
					mw.notify(title + " zaten güncel.");
				} else {
					mw.notify(title + " güncellendi.");
				}
			}).fail(function(...args) {
				mw.notify("Güncelleme başarısız!");
				console.log(...args);
			});
		});
	}); // getScript
};

const button = $("<button>");

button
	.html("Çalışma butonu")
	.attr("id", "update-module");

button.on("click", function () {
	update("Modül:Kategori/tablo");
});

const p = $(".mw-parser-output p:first-of-type");
p.before(button);

} // empty block scope

// </nowiki>