ميدياويكي:Gadget-globalContribs.js

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات (إفراغ الكاش الآن).

/**
 * مساهمات مستخدم على جميع الويكيبيديات
 * الكاتب: ASammour 
 * 
 * تعمل في صفحة [[ويكيبيديا:مساهمات عالمية]]
 */
if (mw.config.get('wgArticleId') === 5950287 & window.globalContribs!==true ){
	window.globalContribs=true;
	
	$("div#globalContribs").html('<div class="cdx-search-input cdx-search-input--has-end-button cdx-typeahead-search__input" ><input class="cdx-text-input__input" placeholder = "أدخل المستخدم هنا" type = "text" id = "global-contribs" /><button class = "cdx-button cdx-search-input__end-button" id = "global-contribs-submit">ابحث</button></div><ul id ="global-contribs-results"></ul>');
	
	
	var langs = [
	    "ace",
		"af",
		"ak",
		"als",
		"an",
		"roa-rup",
		"frp",
		"ast",
		"atj",
		"gn",
		"ay",
		"az",
		"bjn",
		"gor",
		"id",
		"ms",
		"bm",
		"zh-min-nan",
		"map-bms",
		"jv",
		"min",
		"su",
		"bug",
		"bcl",
		"bi",
		"bar",
		"bs",
		"br",
		"ca",
		"ceb",
		"cs",
		"ch",
		"cbk-zam",
		"ny",
		"sn",
		"tum",
		"co",
		"cy",
		"da",
		"pdc",
		"de",
		"nv",
		"dsb",
		"na",
		"et",
		"eml",
		"ang",
		"en",
		"es",
		"eo",
		"ext",
		"eu",
		"ee",
		"to",
		"hif",
		"fo",
		"fr",
		"fy",
		"ff",
		"fur",
		"ga",
		"gv",
		"sm",
		"gag",
		"gd",
		"gl",
		"ki",
		"ha",
		"haw",
		"hsb",
		"hr",
		"io",
		"ig",
		"ilo",
		"ia",
		"ie",
		"ik",
		"xh",
		"zu",
		"is",
		"it",
		"kbp",
		"kl",
		"pam",
		"csb",
		"kw",
		"rw",
		"rn",
		"kg",
		"sw",
		"ht",
		"ku",
		"lad",
		"ltg",
		"la",
		"lv",
		"lb",
		"lt",
		"lij",
		"li",
		"ln",
		"lfn",
		"olo",
		"jbo",
		"lg",
		"lmo",
		"hu",
		"mg",
		"mt",
		"mi",
		"cdo",
		"mwl",
		"fj",
		"nah",
		"nap",
		"nl",
		"nds-nl",
		"cr",
		"frr",
		"pih",
		"no",
		"nrm",
		"nov",
		"nn",
		"uz",
		"oc",
		"om",
		"pfl",
		"pag",
		"pap",
		"jam",
		"pcd",
		"pms",
		"nds",
		"pl",
		"pt",
		"kaa",
		"crh",
		"ty",
		"ksh",
		"ro",
		"rmy",
		"rm",
		"qu",
		"se",
		"sg",
		"sc",
		"sco",
		"stq",
		"nso",
		"st",
		"tn",
		"sq",
		"scn",
		"simple",
		"ss",
		"sk",
		"sl",
		"szl",
		"so",
		"srn",
		"sh",
		"fi",
		"sv",
		"tl",
		"kab",
		"roa-tara",
		"tet",
		"din",
		"vi",
		"tpi",
		"chy",
		"ve",
		"tr",
		"tk",
		"tw",
		"za",
		"vec",
		"vep",
		"vo",
		"fiu-vro",
		"wa",
		"vls",
		"war",
		"wo",
		"ts",
		"yo",
		"diq",
		"zea",
		"bat-smg",
		"el",
		"pnt",
		"av",
		"ady",
		"kbd",
		"ab",
		"ba",
		"be",
		"be-tarask",
		"bxr",
		"bg",
		"inh",
		"os",
		"kv",
		"krc",
		"ky",
		"mrj",
		"kk",
		"lbe",
		"lez",
		"mk",
		"mdf",
		"mn",
		"ce",
		"mhr",
		"koi",
		"rue",
		"ru",
		"sah",
		"cu",
		"sr",
		"tt",
		"tg",
		"tyv",
		"udm",
		"uk",
		"xal",
		"cv",
		"myv",
		"hy",
		"xmf",
		"ka",
		"got",
		"yi",
		"he",
		"ur",
		"ar",
		"ps",
		"sd",
		"pnb",
		"fa",
		"glk",
		"mzn",
		"arz",
		"azb",
		"lrc",
		"ug",
		"ckb",
		"arc",
		"dv",
		"ks",
		"new",
		"ne",
		"pi",
		"bh",
		"dty",
		"gom",
		"mai",
		"mr",
		"sa",
		"hi",
		"as",
		"bpy",
		"bn",
		"pa",
		"gu",
		"or",
		"ta",
		"te",
		"kn",
		"tcy",
		"ml",
		"si",
		"th",
		"my",
		"dz",
		"bo",
		"lo",
		"km",
		"iu",
		"chr",
		"ti",
		"am",
		"ko",
		"zh",
		"zh-classical",
		"wuu",
		"hak",
		"ja",
		"zh-yue",
		"gan",
	];
	
	$("#global-contribs-submit").click(function() {
	    $("#global-contribs-results").empty();
	    var contribs = $("#global-contribs").val();
	    for (var i = 0; i < langs.length; i++) {
	        searching(langs[i], contribs);
	    }
	});
	
	
	function searching(lang, contribs) {
	    if (contribs.split(".").length == 1) {
			$.ajax({
				url: '//' + lang + '.wikipedia.org/w/api.php',
				data: {
					"action": "query",
					"format": "json",
					"list": "usercontribs",
					"uclimit": "10",
					"ucuser": contribs,
					"ucprop": "ids|title|comment"
				},
				dataType: 'jsonp',
				success: function(x) {
					if (x.query.usercontribs.length > 0) {
						var html = "";
						html = '<li><b>' + lang + '</b><ul>';
						$("ul#global-contribs-results").append();
	
						for (var i = 0; i < x.query.usercontribs.length; i++) {
							html = html + "<li><a href = 'https://" + lang + ".wikipedia.org/wiki/special:diff/" + x.query.usercontribs[i].revid + "'>" + x.query.usercontribs[i].revid + " - " + x.query.usercontribs[i].title + "</a>" + "، " + x.query.usercontribs[i].comment + "</li>";
						}
						html = html + '</ul></li>';
						$("ul#global-contribs-results").append(html);
					}
				}
			});
	    }
		
		else{
			$.ajax({
				url: '//' + lang + '.wikipedia.org/w/api.php',
				data: {
					"action": "query",
					"format": "json",
					"list": "usercontribs",
					"uclimit": "10",
					"ucuserprefix": contribs,
					"ucprop": "ids|title|comment"
				},
				dataType: 'jsonp',
				success: function(x) {
					if (x.query.usercontribs.length > 0) {
						var html = "";
						html = '<li><b>' + lang + '</b><ul>';
						$("ul#global-contribs-results").append();
	
						for (var i = 0; i < x.query.usercontribs.length; i++) {
							html = html + "<li><a href = 'https://" + lang + ".wikipedia.org/wiki/special:diff/" + x.query.usercontribs[i].revid + "'>" + x.query.usercontribs[i].revid + " - " + x.query.usercontribs[i].title + "</a>" + "، " + x.query.usercontribs[i].comment + "</li>";
						}
						html = html + '</ul></li>';
						$("ul#global-contribs-results").append(html);
					}
				}
			});
		}
	}	
}