//<pre><nowiki>
$( function() { if(!document.forms.editform) { return; }
name = document.getElementsByTagName("h1")[0].innerHTML.replace("Editing ", "").replace(/ \(.*?\)/, "");
intLast = name.lastIndexOf(" ");
lname = name.substr(intLast + 1);
fname = name.substr(0, intLast);
name = lname + (fname ? ", " + fname : "");
txt = document.editform.wpTextbox1.value;
introTxt = txt.match(/\(([^\)]*?[0-9]{4}[^\)]*?)\)/);
if (introTxt) { years = introTxt[1].match(/[0-9]{4}/g); } else { years = []; }
newTxt = "[[Category:|" + name + "]]" + (years[0] ? "\n[[Category:" + years[0] + " births|" + name + "]]" : "") + (years[1] ? "\n[[Category:" + years[1] + " deaths|" + name + "]]" : "");
mwCustomEditButtons[mwCustomEditButtons.length] = {"imageFile": 'http://up.wiki.x.io/wikipedia/en/b/b1/Button_key.PNG', "speedTip": 'Insert category key', "tagOpen": '', "tagClose": newTxt, "sampleText": ''}; } );
//</nowiki></pre>