משתמש:Guycn2/EditCounterTab.js – הבדלי גרסאות
תוכן שנמחק תוכן שנוסף
אין תקציר עריכה |
לא תמיד יש history |
||
שורה 34: | שורה 34: | ||
case 2: |
case 2: |
||
case 3: |
case 3: |
||
$('#ca- |
$('#ca-edit').before(editCounterTabElement); |
||
editCounterTabElement.on('click',editCounterTabClick); |
editCounterTabElement.on('click',editCounterTabClick); |
||
break; |
break; |
גרסה מ־08:16, 17 באפריל 2017
/* Adding a tab that shows the number of edits made by the user + link to edit counter.
Based on [[user:Yonidebest/monobook.js/editCounterTab.js]]
Contributors:
# [[User:החבלן]]
# [[User:Guycn2]]
*/
(function(mw){
'use strict';
var editCounterTabElement = $('<li id="ca-contrib"><span><a id="countrib-link-buttun" style="cursor:pointer;" title="הצגת מספר העריכות של המשתמש">מונה עריכות</a></span></li>');
function editCounterTabClick(evt) {
var username = mw.config.get('wgRelevantUserName');
var contriblink = document.getElementById('countrib-link-buttun');
contriblink.innerText = 'טוען...';
contriblink.title = 'הצגת מונה העריכות של המשתמש';
contriblink.target = 'blank';
editCounterTabElement.off('click', editCounterTabClick);
evt.preventDefault();
if (mw.util.isIPAddress(username)){
$.get(window.location.origin+'/w/api.php?action=query&format=json&list=usercontribs&uclimit=max&ucuser=' + encodeURIComponent(username), function(data){
contriblink.innerText = data.query.usercontribs.length;
contriblink.href = 'https://he.wikipedia.org/wiki/מיוחד:תרומות/' + username;
});
}else{
$.get(window.location.origin+'/w/api.php?action=query&list=users&ususers=' + encodeURIComponent(username) + '&usprop=editcount&format=json&continue=', function(data){
contriblink.innerText = data.query.users[0].editcount;
contriblink.href = 'https://tools.wmflabs.org/xtools-ec/?user=' + username + '&project=he.wikipedia&uselang=en-ca';
});
}}
switch (mw.config.get('wgNamespaceNumber')) {
case 2:
case 3:
$('#ca-edit').before(editCounterTabElement);
editCounterTabElement.on('click',editCounterTabClick);
break;
}
})(mw);