User:Kiran Gopi/useredits.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Kiran Gopi/useredits. |
- Report page listing warnings and errors.
// <pre>
function liveEditCounter(username)
{
var xhr;
var headingBkUp = document.getElementById("firstHeading").innerHTML;
try { xhr = new XMLHttpRequest(); }
catch(e)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200 || xhr.status == 0) {
var jsonOutput = eval('(' + xhr.responseText + ')');
document.getElementById("firstHeading").innerHTML = headingBkUp + " (Edits: " +
jsonOutput.query.users[0].editcount + ")";
}
}
};
xhr.open('GET', "http:///commons.wikimedia.org/w/api.php?action=query&list=users&ususers="+username+"&usprop=editcount&format=json", true);
xhr.send(null);
document.getElementById("firstHeading").innerHTML = headingBkUp +
" <img src='http://upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif' />";
}
function OpenContributions()
{
window.location = "http://ml.wikipedia.org/wiki/Special:Contributions/" + encodeURIComponent( mw.config.get('wgTitle') );
}
$(function() {
if (mw.config.get('wgTitle').indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history
return;
if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk") {
var username = encodeURIComponent( mw.config.get('wgTitle') );
liveEditCounter(username);
mw.util.addPortletLink( 'p-cactions', "javascript:OpenContributions()", "സംഭാവനകൾ", "Contribs", "ഉപയോക്താവിന്റെ സംഭാവനകൾ", "");
}
});
//<pre>