Kullanıcı:Doğu/GlobalEdit.js

Vikipedi, özgür ansiklopedi
Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.
function liveEditCounter(username) {
    if (!document.getElementById('edit-count-id') || !document.getElementById('edit-count-info'))
        return;
    var count="";
    if (mw.config.get('wgUserName') == mw.config.get('wgTitle'))
    {
        count = mw.config.get('wgUserEditCount');
    } else {
        var xhr;
        try { xhr = new XMLHttpRequest();
        } catch(e) {
            xhr = new ActiveXObject(Microsoft.XMLHTTP);
        }

        xhr.onreadystatechange  = function() {
            if(xhr.readyState  == 4) {
                if(xhr.status  == 200) {
                    var doc = xhr.responseXML;
                    count = doc.getElementsByTagName('user')[0].getAttribute('editcount')
                }
            }
        };

        xhr.open('GET', "http://en.wikipedia.org/w/api.php?action=query&list=users&usprop=editcount&format=xml&ususers="+username, true);
        xhr.send(null);
    }
    if(!count) count="0";
    count = (count+'').replace(/(?=(?:\d{3})+$)(?!^)/g, ',');
    $('#edit-count-id').text(count); 
    $('#edit-count-info').text(count); 
}

$(function() {
  if ($.inArray(mw.config.get('wgCanonicalNamespace'), ["Kullanıcı" , "Kullanıcı_mesaj"]) !== -1) {
     var username = encodeURIComponent( mw.config.get('wgTitle').split("/")[0] );
     liveEditCounter(username);
  }
});