User:Kanegasi/editcounter

Description
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–15 minutes, then you should start to worry, unless you have 40,000+ edits.

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

Set up
The following code goes in your common JavaScript page at common.js.

// Counts all your edits and saves them to a page ( http://www.minecraftwiki.net/wiki/User_talk:Kanegasi/editcounter.js ) if (mw.config.get('wgTitle') === mw.config.get('wgUserName') && mw.config.get('wgNamespaceNumber') === 2) { var pageName = 'edit count'; var scriptPage = 'User:Kanegasi/editcounter.js'; var transcludeAll = false; var tableHeaders = false; var mainDivAttrib = ''; var mainTableAttrib = ''; var topRowAttrib = ''; var bottomRowAttrib = ''; mw.loader.load('http://www.minecraftwiki.net/index.php?title=User:Kanegasi/editcounter.js&action=raw&ctype=text/javascript'); }

The lines in the middle contain variables to modify how the script acts, like table format and where the table is saved. A final note is that these vars are not active until you run the script again. When finding the right options, it is highly suggested to edit the page where the table is at, using the Show preview button. Once a desired format is achieved, copy the appropriate settings into the appropriate variable and test the script to see if it will make that table each time. Please do not edit your common.js page for each var change and run the script.
 * 1)   — 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 that page if you want to keep it or replace   with the name of the page you want to create between the single quotes on the first line.
 * 2)   — this is the location of the script, but has no bearing on where the script loads from (see last line of this code). When the script posts the results of the count, it puts a link in the edit summary using what's set here. That way, people see how your "edit count" page got its numbers. This option is here so that if you want to put the script on your own page or copy it over to another MediaWiki-powered site, you can easily link to that page instead.
 * 3)   — this sets one of two transclude options.
 * 4) *  — transcludes only the total edit count and date last counted. Both of these values come out as plain text when you put   on any other page, ignoring the rest of the table. Using the selective transclusion function, you can transclude just the total count or the date using the section names count and date.
 * 5) *  — transcludes the whole table normally when using the mentioned  code. Ignores the section names if you try to use them.
 * 6)   — this is for the namespace row. Setting to   sets up that row like table headers using the !! wikitable code. Setting this to   treats that row like normal cells.
 * 7)   — these values allow you to customize the look and behavior of the table, such as styles, classes, etc. which are all optional.
 * 8) *  — this is the main container, where overall stuff like   should be.
 * 9) *  — this one is for the whole table, such as cellpadding, cellspacing, class="wikitable", margins, etc.
 * 10) *  — this is for the top row with the namespace labels.
 * 11) *  — this is for the bottom row with the contribution numbers.
 * 12)   — this is the only required line from the code above. This loads the script for use.

It is recommended to run the script no more than once a week (as long as once a month if you have a lot of edits). Running this script often, or several people running it often, can be a possible wiki server burden.

Usage
When you visit your main userpage, you will see an extra link in the Toolbox, right after the "User contributions" link. It will be labeled "Edit counter v#" where the # indicates the current script version. Just click the button and the script will execute. While it is working, the button should change to "Processing..." (sometimes it won't, this is normal), and when it is done it will either say "Success!" or "Error!". From there you can go look at the table in your userspace, or load/refresh the page you have it transcluded into.

If you believe the most recent version of the script was not loaded, follow the directions at the top of your common.js page while on your user page. This will force your browser to reload the page from the Internet.

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, where "edit count" is the default page name, which can be changed as described above. Alternatively, you can just copy/paste the table code from the table page and use it.

Bugs
Let me know on my talk page if there are any problems, and I'll attempt to resolve them.

Count discrepancy
The discrepancy between the total edit count 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 and page protections are present on your contribution list, but don't increment your running total. Currently, the script will subtract log events such as moves, protections, deletions and anything else not an edit from the namespace counts, and page moves are probably the biggest difference. File uploads and overwrites are the only log events counted. There is a slight oddity where deleted files are also counted.

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. I plan on eventually researching every single log event available and finding out whether or not it increments the total in order to get a more accurate count for later script versions.