User:Frietjes/condense.js

// jQuery(document).ready(function($) {	if(mw.config.get('wgNamespaceNumber') != -1) {	mw.loader.using(['mediawiki.util']).done( function { if(document.getElementsByClassName('mw-userlink').length > 0) { var portletlink = mw.util.addPortletLink('p-tb','#','Condense history','t-condh'); $(portletlink).click(function(e) {				e.preventDefault;				wpCondenseHistory;			}); }		if(document.getElementsByName('wpSummary').length) { var portletlink = mw.util.addPortletLink('p-tb','#','Condense summary','t-conds'); $(portletlink).click(function(e) {				e.preventDefault;				wpCondenseEditSummary;			}); }	});	} // //

function wpCondenseHistory {	var span_elements = document.getElementsByClassName('mw-userlink'); var editors = []; var seen = {}; seen ["User:Addbot"] = true; seen ["User:AnomieBOT"] = true; seen ["User:CommonsDelinker"] = true; seen ["User:Cydebot"] = true; seen ["User:EmausBot"] = true; seen ["User:Filedelinkerbot"] = true; seen ["User:FrescoBot"] = true; seen ["User:IznoRepeat"] = true; seen ["User:KLBot2"] = true; seen ["User:KolbertBot"] = true; seen ["User:Monkbot"] = true; seen ["User:PrimeBOT"] = true; seen ["User:SporkBot"] = true; seen ["User:WildBot"] = true; seen ["User:Frietjes"] = true; for( var i=(span_elements.length - 1); i>=0; i--) { var e = span_elements[i].getAttribute('title'); if( e !== null) { e = e.replace(/ \(page does not exist\)/g, ''); e = e.replace(/Special:Contributions\//g, 'User:'); if (seen.hasOwnProperty(e) === false) { seen[e] = true; editors.push(e); }		}	}	alert(editors.join(', ')); }

// //

function wpCondenseEditSummary {   var wpSummary = document.getElementsByName('wpSummary'); // Avoid TypeError: document.getElementsByName(...)[0] is undefined if(!wpSummary || !wpSummary[0]) return; var editsummary = wpSummary[0].value; var a = editsummary.replace(/^([^,]*)(User:.*)$/, '$1'); editsummary = editsummary.replace(/^([^,]*)(User:.*)$/, '$2'); var items = editsummary.split(/[\s]*,[\s]*/g);

var editors = []; var seen = {}; for( var i=0; i<items.length; i++) { var e = items[i]; if( e !== null) { if (seen.hasOwnProperty(e) === false) { seen[e] = true; editors.push(e); }		}	}	document.getElementsByName('wpSummary')[0].value = a + editors.join(', '); }

});