Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/***********************************************************************************/
/* Edit counter script                                                             */
/*   author:        User:Najzere @ strategywiki.org                                */
/*   source:        http://strategywiki.org/wiki/User:Najzere/edit counter.js      */
/*   documentation: http://strategywiki.org/wiki/User talk:Najzere/edit counter.js */
/*   contact:       http://strategywiki.org/wiki/User talk:Najzere                 */
/*   license:       CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)  */
/* Customized by බිඟුවා*/
/***********************************************************************************/

// Only add edit count button on user pages
if (wgTitle == wgUserName && wgNamespaceNumber == 2) {
  addOnloadHook(makeEditCountButton);
}

// Add a new link after "User contributions" in the toolbox
function makeEditCountButton() {
  if (!document.getElementById('t-contributions')) {
    alert('අපේක්ෂිත මූලාවයව ස්ථාපනය කර නොමැත. කරුණාකොට http://si.wiktionary.org/wiki/User_talk:බිඟුවා බලන්න.');
    return;
  };
  var newlist = document.createElement('li');
  newlist.id = "t-editcounter";
  var newlink = document.createElement('a');
  newlink.href = 'javascript:countEdits()';
  var linkname = document.createTextNode('සංස්කරණය ගණකය');
  newlink.appendChild(linkname);
  newlist.appendChild(newlink);
  document.getElementById('t-contributions').parentNode.insertBefore(newlist, document.getElementById('t-contributions').nextSibling);
}

function countEdits() {
// Change edit counter link to let the user know it's thinking
  document.getElementById('t-editcounter').getElementsByTagName('a')[0].innerHTML = 'ගණනය කරමින්...';

// Set up variables
  if (wgServer == 'http://si.wiktionary.org') {
    var editSummary = '[[User:බිඟුවා/edit counter.js|edit counter.js]] මගින් සංස්කරණය කිරීම';
    var tableTop = '[[User:බිඟුවා/edit counter.js|සම්පූර්ණ සංස්කරණ සංඛ්‍යාව]]';
  } else {
    var editSummary = 'http://si.wiktionary.org/wiki/User:බිඟුවා/edit_counter.js මගින් සංස්කරණය කිරීම';
    var tableTop = '<span class="plainlinks">[http://si.wiktionary.org/wiki/User:බිඟුවා/edit_counter.js සම්පූර්ණ සංස්කරණ සංඛ්‍යාව]</span>';
  };
  if (typeof editPage == 'undefined') {editPage = 'දායකත්වය '};
  if (typeof tableClass == 'undefined') {tableClass = ''};
  if (typeof tableStyle == 'undefined') {tableStyle = ''};
  if (editPage == '') {editPage = 'දායකත්වය'};
  var skipcaptcha = false;
  var oldpage = false;
  var edits;
  var moves;
  var namespaces = new Array();
  var namespacessinhala = new Array();
  var movelog = new Array();
  var protectlog = new Array();
  var deletelog = new Array();
  var uploadlog = new Array();
  var next;
  var edittoken;
  var imageupload;
  var blockcount;
  var rightscount;
 var importcount;
 var patrolcount; 
 var deletecount; 
 var movecount; 
  var brace = '{';
  var table = '{| class="wikitable '+tableClass+'" style="'+tableStyle+'"\n!colspan="5"| '+tableTop+': '+brace+brace+'subst:formatnum:';

// Check if the user is autoconfirmed
  for (var right in wgUserGroups)
    if (wgUserGroups[right] == 'autoconfirmed') {skipcaptcha = true};

// Get full edit count, as tracked by MW, add it to table
  queryApi('action=query&meta=userinfo&uiprop=editcount', function(uiResponse) {
    table += uiResponse.query.userinfo.editcount+'}}';
  });

// Initialize namespace, move log and patrol log arrays
  queryApi('action=query&meta=siteinfo&siprop=namespaces', function(siResponse) {
    for (var ns in siResponse.query.namespaces) {
      if (siResponse.query.namespaces[ns].id > -1) {
        if(siResponse.query.namespaces[ns].id != namespaces.length)
          break;
        if (siResponse.query.namespaces[ns].id == 0) {
          namespaces[siResponse.query.namespaces[ns].id] = 'ප්‍රධාන';
        } else {
          namespaces[siResponse.query.namespaces[ns].id] = siResponse.query.namespaces[ns].*;
        };
        movelog[siResponse.query.namespaces[ns].id] = 0;
        protectlog[siResponse.query.namespaces[ns].id] = 0;
        deletelog [siResponse.query.namespaces[ns].id] = 0;
        uploadlog [siResponse.query.namespaces[ns].id] = 0;
      };
    };
  });

// Fill move log array
  next = '';
  while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=move&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(moveResponse) {
      for (var item in moveResponse.query.logevents) {
        movelog[moveResponse.query.logevents[item].ns] += 1;
      }
      if (moveResponse["query-continue"]) {
        next = '&lestart='+moveResponse["query-continue"].logevents.lestart;
      } else {
        next = 'stop';
      };
    });
  }

// Fill patrol log array
  next = '';
  while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=protect&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(protectResponse) {
      for (var item in protectResponse.query.logevents) {
        protectlog[protectResponse.query.logevents[item].ns] += 1;
      }
      if (protectResponse["query-continue"]) {
        next = '&lestart='+protectResponse["query-continue"].logevents.lestart;
      } else {
        next = 'stop';
      };
    });
  }

// Fill deletelog array
  next = '';
  while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=delete&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(deleteResponse) {
      for (var item in deleteResponse.query.logevents) {
        deletelog [deleteResponse.query.logevents[item].ns] += 1;
      }
      if (deleteResponse["query-continue"]) {
        next = '&lestart='+deleteResponse["query-continue"].logevents.lestart;
      } else {
        next = 'stop';
      };
    });
  }


// Loop through namespaces counting images upload
    next = '';
    imageupload= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=upload&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(uploadResponse) {
        imageupload+= uploadResponse.query.logevents.length;
        if (uploadResponse["query-continue"]) {
          next = '&ucstart='+uploadResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };

// Loop counting blockcount
    next = '';
    blockcount= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=block&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(blockResponse) {
        blockcount+= blockResponse.query.logevents.length;
        if (blockResponse["query-continue"]) {
          next = '&ucstart='+blockResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };

// Loop counting rightscount
    next = '';
    rightscount= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=rights&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(rightsResponse) {
        rightscount+= rightsResponse.query.logevents.length;
        if (rightsResponse["query-continue"]) {
          next = '&ucstart='+rightsResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };

// Loop counting importcount
    next = '';
    importcount= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=import&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(importResponse) {
        importcount+= importResponse.query.logevents.length;
        if (importResponse["query-continue"]) {
          next = '&ucstart='+importResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };

// Loop counting patrolcount
    next = '';
    patrolcount= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=patrol&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(patrolResponse) {
        patrolcount+= patrolResponse.query.logevents.length;
        if (patrolResponse["query-continue"]) {
          next = '&ucstart='+patrolResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };

// Loop counting deletecount
    next = '';
    deletecount= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=delete&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(deleteResponse) {
        deletecount+= deleteResponse.query.logevents.length;
        if (deleteResponse["query-continue"]) {
          next = '&ucstart='+deleteResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };


// Loop counting movecount
    next = '';
    movecount= 0;
    while (next != 'stop') {
    queryApi('action=query&list=logevents&letype=move&leuser='+wgUserName+'&lelimit=max&leprop=title'+next, function(movecountResponse) {
        movecount+= movecountResponse.query.logevents.length;
        if (movecountResponse["query-continue"]) {
          next = '&ucstart='+movecountResponse["query-continue"].logevents.ucstart;
        } else {
          next = 'stop';
        };
      });
    };


if (imageupload> 0) {
   table += '\n|-\n|colspan="2" align="center"|පින්තූර උඩුගත කිරීම් ගණන|| colspan="3" align="center"|'+ imageupload+'';
  };
if (blockcount> 0) {
   table += '\n|-\n|colspan="2" align="center"|වාරණය කිරීම් ගණන|| colspan="3" align="center"|'+ blockcount+'';
  };
if (rightscount> 0) {
   table += '\n|-\n|colspan="2" align="center"|හිමිකම් වෙනස් කිරීම් ගණන|| colspan="3" align="center"|'+ rightscount+'';
  };
if (patrolcount> 0) {
   table += '\n|-\n|colspan="2" align="center"|මුර සංචාරයන් ගණන|| colspan="3" align="center"|'+ patrolcount+'';
  };
if (deletecount> 0) {
   table += '\n|-\n|colspan="2" align="center"|මකා දැමීම් ගණන|| colspan="3" align="center"|'+ deletecount+'';
  };
if (movecount> 0) {
   table += '\n|-\n|colspan="2" align="center"|ගෙන යාම් ගණන|| colspan="3" align="center"|'+ movecount+'';
  };

table += '\n|-\n|colspan="5" align="center"|සවිස්තර දත්තයන්';

table += '\n|-\n| නාමවකාශය ||සංස්කරණය කිරීම් ||ගෙනයාම්||ආරක්ෂා කිරීම්||මකා දැමීම්';

// Loop through namespaces counting edits and subtracting page moves and patrols
  for (var i = 0; i < namespaces.length; i++) {
    next = '';
    edits = 0;
    while (next != 'stop') {
      queryApi('action=query&list=usercontribs&ucuser='+wgUserName+'&uclimit=max&ucdir=newer&ucnamespace='+i+next, function(ucResponse) {
        edits += ucResponse.query.usercontribs.length;
        if (ucResponse["query-continue"]) {
          next = '&ucstart='+ucResponse["query-continue"].usercontribs.ucstart;
        } else {
          next = 'stop';
        };
      });
    };

    edits = edits - movelog[i] - protectlog[i];
    if (edits > 0) {
      table += '\n|-\n| '+namespaces[i]+' || '+brace+brace+'subst:formatnum:'+edits+'}} || '+movelog[i]+'|| '+protectlog[i]+' ||' +deletelog[i]+ ' ';
    };
  };



  table += '\n|-\n|colspan="5" align="center"| <small>අවසාන ගණනය කිරීම සිදු වූයේ: '+brace+brace+'subst:#time:F j, Y}}</small>\n|}';

// Get edit token and check if we'll be creating a new page (in the case of non-autoconfirmed users)
  queryApi('action=query&prop=info|revisions&intoken=edit&titles=User:'+wgUserName+'/'+editPage, function(propResponse) {
    for (var page in propResponse.query.pages) {
      edittoken = propResponse.query.pages[page].edittoken.replace(/\+\\$/g,'%2B%5C');
      if (propResponse.query.pages[page]["revisions"]) {
        oldpage = true;
      };
    };
  });

// If the user is not autoconfirmed and we're creating a new page, kick out of the script
  if (!skipcaptcha && !oldpage) {
    alert("කනගාටුයි, ඔබ ස්වයං-චිරස්ථිත පරිශීලකයෙක් නොවේ.  එම නිසා මෙම පිටුව සාදා: User:"+wgUserName+"/"+editPage+", ආපසු අත්හදා බලන්න.");
    document.getElementById('t-editcounter').getElementsByTagName('a')[0].innerHTML = 'දෝෂය!';
    return;
  };

// Edit the target page with the table, change edit count link to reflect the status of the page save
  queryApi('action=edit&title=User:'+wgUserName+'/'+editPage+'&summary='+editSummary+'&minor=1&recreate=1&bot=1&text='+table+'&token='+edittoken, function(actionResponse) {
    if (actionResponse.edit.result == "Success") {
      document.getElementById('t-editcounter').getElementsByTagName('a')[0].innerHTML = 'අවසානයි!';
    } else {
      document.getElementById('t-editcounter').getElementsByTagName('a')[0].innerHTML = 'දෝෂය!';
    };
  });
}

// Accepts an API query and callback function for handling queries from the main function
function queryApi(query, callback) {
  try {
    var xmlRequest = new XMLHttpRequest();
  } catch(e) {
    try {
      var xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
      var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        throw "Could not create an XmlHttpRequest";
        }
      }
    }

  xmlRequest.open('POST', wgScriptPath+'/api.php', false);
  xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  xmlRequest.send(query+'&format=json');
  var xmlResponse = new Function("return "+xmlRequest.responseText)();
  if (!xmlResponse) {
    alert('Problem retrieving information');
  } else {
    callback(xmlResponse);
  };
}
"https://si.wiktionary.org/w/index.php?title=පරිශීලක:බිඟුවා/edit_counter.js&oldid=11122" වෙතින් සම්ප්‍රවේශනය කෙරිණි