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. You need JavaScript enabled in your browser in order to use this script and you must be a part of the autoconfirmed user group in order to use the script for the first time with no problems. If not, you need to manually create the page where your edit count will be and then run the script.


 * 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 5 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 code in the dotted box below must be copied exactly how it is, without changing my username, into either your common JavaScript page at common.js or your vector skin page at vector.js. You can use other .js pages for other skins, but I cannot guarantee it will work on all skins. As long as the skin has a "User contributions" link somewhere, it should work. If you want to use this script on another wiki, you must use your .js page at that wiki.


 * All you need to run the script is what is in the dotted box below. The script will run based upon who is logged in at your computer, not where the script is at. My username is there because the script is in my userspace, so if you change it the script won't load unless you have your own copy. This script should work on all MediaWiki installations using version 1.18 and above. Go to the "Special:Version" page on your site to see your site's version.


 * Note: Copying the entire main script to your own space is not required, even if you are not on Wikipedia. If you want to make your own changes to the script, as I did using the original author's version, then you can copy the script and do what you want with it, as long as what I have at the top of the script is not removed.

/* Counts all your edits and saves them to a page ( http://en.wikipedia.org/wiki/User:Kanegasi/editcounter ) */ if (mw.config.get('wgTitle') === mw.config.get('wgUserName') && mw.config.get('wgNamespaceNumber') === 2) { /* begin options */

/* end options */ mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Kanegasi/editcounter.js&action=raw&ctype=text/javascript'); }


 * The following is some options you can place in between the "options" lines in the code above. These change how the script acts and how the resulting table is displayed. Place your option customization in between the single quotes, and you MUST place a backslash (\) before any apostrophes you intend to use, for example: . If the option uses true or false, single quotes are not required.
 * The defaults are how the script runs if you don't use that option. If you like the default, you don't have to put the option in. One option per line and you can remove the begin/end option lines, they're just there to keep the option thing simple.


 * Below this table is an example table layout showing where the variables go.

Example table layout
 namespace   namespace etc.    (if tableHeaders=false:   namespace   namespace etc.)   numbers 

Usage

 * When you visit your userpage, you will see an extra link under Tools, 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 will change to "Processing…" 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.


 * 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  to print out the whole table. The date you last ran the script and your total count are posted in subpages of the main edit count table so you can transclude those separately, as noted on the option table above.


 * Important notes :


 * 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.


 * Those "var options" 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.


 * It is recommended to run the script no more than once a week, preferably once a month. Running this script often, or several people running it often, clogs up the recent changes, is an unnecessary server burden, and is generally frowned upon.
 * When  is set to , this script creates/edits three pages at a time, so please use it sparingly to avoid recent changes spam.

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, it's all your deleted edits. The script counts every contribution you can view on your Special:Contributions page, but moves, protects, and file overwrites do not increment your running total on your Preferences page. These three types of contributions are subtracted from the counted total this script creates and the difference between the script's total and the wiki's total is any deleted edits you may have, which are annotated in a tooltip on your total count. The only exception is that counting file overwrites seems to include overwrites of deleted files, basically counting those deletions twice (and decreasing your file namespace count a little bit).


 * Deleted edits can be any revisions on a page that was deleted, or hidden revisions. The reason why deleted edits are tracked by the wiki software is because there's no process available to subtract from a user's count when something gets deleted. They contributed, the count increased, but the count does not decrease when the contribution "goes away" from public/API view.


 * There may be other contributions that could show up in a revision history, such as any special extension your wiki may use, but they are unidentified at this time. I have tested the script on a relatively small account and an active admin account and both provided accurate counts.

Credits

 * I have linked to the original script a few times on this page, and have several links at the top of my script, but I feel a credit section wouldn't hurt. This script was originally written by Najzere of strategywiki.org.


 * I knew next to nothing about JavaScript before tackling this script and it all started when I found a modified version of the script in use by Matt of minecraftwiki.net, which most of my wiki experience lies. This is when I figured out what he already figured out, the API calls on Najzere's script were using the /w/api.php script path which didn't work on minecraftwiki.net's MediaWiki install, but did on Wikipedia, which explained Najzere's bug mention of higher namespaces on Wikipedia not being counted, proving people have used the script outside of strategywiki. Before I came to this conclusion, though, I slowly gave myself a crash-course in JavaScript, learning almost every bit of the script, refining it and making my own changes. That bug has since been rectified in my version and the script catches all namespaces.


 * Most of my learning came from sites such as w3schools.com and especially stackoverflow.com. I ran into, and learned about, interesting things that most script makers and wiki editors would know, like the wiki cache in regards to images and scripts or using pre-save transform parser functions in a script. Silly little things that any super curious Internet goer would eventually learn. I have come a long way from stumbling across the script last December. It still doesn't do exactly what the original script does (vertical table as opposed to the horizontal alignment Matt gave it) but that is my goal, when I get to it.