User talk:Najzere/edit counter.js

This script counts your contributions and breaks them down by namespace, then writes a table with the information to a page in your userspace. Obviously, the script requires that you have JavaScript enabled. If you aren't autoconfirmed yet, you should create the page in your userspace beforehand to deal with the captchas (if you don't, you'll be prompted to when the script runs).

The script can take a while to run (several minutes if your edits are in the thousands), so be patient. If your browser tells you it's taking too long, you can allow it to continue and it will eventually finish. If it takes longer than 10 minutes, then you should start to worry, unless you have 40,000+ edits.

Don't run the edit counter all the time. For a simple total of all your contributions, you can use the edit count from your preferences. Abuse of this script may result in it being taken away.

You can ask on my talk page if you have any questions or suggestions, or need help setting it up.

Set up
In your skin's JavaScript page – User:Your name/BlueCloud.js by default – paste the following code:

 var editPage = 'Edit count'; var tableClass = ''; var tableFloat = ''; importScript('User:Najzere/edit_counter.js');

The first three lines contain variables to modify how the table is presented.
 * 1) var editPage = 'Edit count'; — this sets the name of the page within your userspace. The default is "Edit count", which would create a page at User:Your name/Edit count. If you already have something there it will be overwritten (it overwrites the old table every time you run it), so you can move the page if you want to keep it or replace Edit count with the name of the page you want to create between the single quotes on the first line.
 * 2) var tableClass = '' ; — this is where you can put extra classes for the table. By default, the table just uses prettytable. To add extra classes, put the ones you want between the single quotes in the second line. Note that the table uses colspans, so the "sortable" class won't work. Here are some options:
 * 3) * collapsible collapsed: This makes the table collapsible and it starts out collapsed.
 * 4) * collapsible: This makes the table collapsible, but it starts out expanded.
 * 5) * other: You can put any custom classes you have in your user CSS page to make the table look different. Note that only you will be able to see these changes.
 * 6) var tableFloat = '' ; — this makes the table float to the left, right or not at all (the default). Acceptable options are: left, right</tt> or leave the single quotes empty. To change this, add left</tt> or right</tt> between the single quotes on the third line.

Usage
When you visit your main userpage, you will see an extra link in the Toolbox (at the top right of the page in the BlueCloud skin) labeled "Edit counts". Just click the button and the script will execute. While it is working, the button should change to "Calculating...", and when it is done it will either say "Done!" or "Error!". From there you can go look at the table in your userspace, or load/refresh the page you have it transcluded into.

Output
The table is by itself on a separate page so that you can easily transclude it wherever you want. You can do so by using  </tt>, where Table page normally defaults to Edit count unless you changed it in the JavaScript. Alternatively, you can just copy/paste the table code from the table page and use it.

Note: Unless you've set the table to float left or right, it will attempt to expand to 100% of wherever you put it. This means if you want to make it smaller, you should wrap it in a  with the width set to whatever you want.

Bugs
Let me know on my talk page if there are any problems, and I'll attempt to resolve them. At this time I've only verified the script works for Firefox 3.5.7 in the Windows 7 operating system.

Count discrepancy
The discrepancy between the total edit count at the top of the table and the sum of the different edit counts by namespace is not a bug. The total edit count comes from a running total the wiki keeps track of (as seen in your preferences), while the edit counts by namespace come from your contribution list. Certain events, such as page moves, page protections and uploading new versions of images are present on your contribution list, but don't increment your running total. Currently, the script will subtract page moves and page protections from the namespace counts, and page moves are probably the biggest difference. Getting a count of how many uploads were overwrites currently takes way too long, so if there is any remaining discrepancy, it likely lies there. There may be other differences, such as deleted edits not showing up in your contribution list but incrementing your running total, but they are unidentified at this point.