User:Ely1/vector.js

/*  adds an editcount tab in userpages and talk pages. first click shows number of total edits. second click opens edicounter page.

created by User:Yonidebest

var editCounterTabClick = false; function editCounterTab {

var username = wgTitle.split('/')[0];

if (!editCounterTabClick) { // tab has never been clicked before

var contriblink = document.getElementById('ca-contrib').childNodes[0]; contriblink.innerHTML = 'טוען...'; contriblink.title = 'עבור לדף תרומות המשתמש';

var a = sajax_init_object; a.open('GET', 'http://he.wikipedia.org/w/api.php?action=query&list=users&ususers=' + encodeURIComponent(username) + '&usprop=editcount', true); a.onreadystatechange = function { if (a.readyState != 4) return;

var ecRX = /editcount=&quot;(\d+)\&quot;/ a.responseText.match(ecRX); var editcounter = RegExp.$1;

var thousandRx = /([0-9]+)([0-9]{3})/ while (thousandRx.test(editcounter)) editcounter = editcounter.replace(thousandRx, "$1,$2");

var contriblink = document.getElementById('ca-contrib').childNodes[0]; contriblink.innerHTML = editcounter; }; a.send(null);

editCounterTabClick = true;

} else { // tab has been clicked before window.location.href = "http://toolserver.org/~vvv/yaec.php?wiki=hewiki_p&user=" + username; } }

$(function { if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3)  addLink((skin == 'vector') ? 'p-views' : 'p-captions', "javascript:editCounterTab", 'ת', 'ca-contrib', 'הצג מספר עריכות', "", "ca-history"); });