User:Blueeighthnote/common.js

function inits { function deletes(link,parent) { var title = link.replace('/wiki/',''); var url = wgServer+'/api.php?action=query&prop=info&intoken=delete&titles='+title+'&format=json'; var deleteReason = "Spam"; $.getJSON(url, function(data) {					if (!deleteReason) return;					var token = mw.user.tokens.get( 'editToken' );					var url = wgServer+'/api.php?action=delete&title='+title+'&reason='+encodeURIComponent(deleteReason)+'&format=json&token='+encodeURIComponent(token);					$.post(url, function(data) { if ( data.error ) { alert( lng.errorapi + ' "' + data.error.code + '": ' + data.error.info ); } else { $(parent).remove; }					});				});			} //Add button below each comment $( "li.activity-type-talk.activity-ns-1" ).each(function {	$(this).append('Delete comment from here '); }); //Change html with lng $( "a.Deletefrom" ).click(function {	var parents = $(this).parent;	text = $(parents).find('a.title').html;       if (confirm("Supprimer les commentaires depuis " + text + " ?")) {	$( "li.activity-type-talk.activity-ns-1" ).each(function { if ($(this).find('a.title').html != text) { deletes($(this).find('a.title').attr('href'),$(this)); } else { return false; }	});       }	}); } // If user can block and delete comments in this wiki, init the script var ug = wgUserGroups.join(' '); if (ug.indexOf('helper') + ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') > -4) { inits; }