From Wikipedia, the free encyclopedia
Jump to navigation Jump to search


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[edit]

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 ( ) */
if (mw.config.get('wgTitle') === mw.config.get('wgUserName') && mw.config.get('wgNamespaceNumber') === 2) {
/* begin options */

/* end options */

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: Kanegasi\'s edit count. 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.

Code Description Default
var pageName = ''; Sets the name of the page where the table is placed.
Example: var pageName = 'my edits'; will place the table at User:Your name/my edits
edit count
var subPages = 'true'; Enables the next two options, which are subpages of the edit count table.
Enabling this causes the script to create/edit three pages at once.
var datePageName = ''; Sets the name of the page where the last date counted is placed.
Example: var datePageName = 'time'; will place the date at User:Your name/my edits/time assuming the main page name is still "my edits" from above
edit count/date
var totalPageName = ''; Sets the name of the page where the total count number is placed.
Example: var totalPageName = 'numbers'; will place the table at User:Your name/my edits/numbers assuming the main page name is still "my edits" from above
edit count/total
var summaryLink = ''; What the script links to in the edit summary when editing the page. You can link to any page on your wiki or use an Interwiki link. Put here exactly what you would use for a wiki link, just without the [[double brackets]]. The default link text in the summary is "updated" (the text you click for the link), but you can provide your own by using a bar (|) after the linked page and then your text.
Example: var summaryLink = 'Special:RecentChanges|indubitably'; will link to Special:RecentChanges but display as indubitably
links to this page
var tableCaption = '';

(see below for layout)
The caption or title of the table. This is bold and centered text on top of the table in a borderless row. None
var tableHeaders = true;

(see below for layout)
Setting to true sets up the namespace (top) row like table headers (like the Code, Description, and Default headers on this table). Setting this to false treats that row like normal cells. true
var nameSpaces = new Array();
nameSpaces[#] = 'name';
Allows you to set custom labels for namespaces. You must have the first line, only once, and before the second line. The pound sign is the namespace id. See Wikipedia:Namespace for namespace ids.
var nameSpaces = new Array();
nameSpaces[3] = 'social';
nameSpaces[8] = 'MW';
will rename the "User talk" namespace into "social" and the "MediaWiki" namespace into "MW"
Normal names
var mainTableAttrib = '';

(see below for layout)
Whole table attributes, such as cellpadding, cellspacing, class="wikitable", and the style="" options.
Example: var mainTableAttrib = 'class="wikitable" style="margin: 0 auto 1em; text-align: center"'; will give the generic wikitable class, centers the table on the page, gives a small margin between the bottom of the table and any other page content, and centers all text.
style="margin: 0 auto 1em;
text-align: center"
var topRowAttrib = '';

(see below for layout)
For the top row with the namespace labels. This will be ignored if var tableHeaders is set to true and your table has class="wikitable" set. You can work around this by setting your own mainTableAttrib without the class and putting style="font-weight:bold" in topRowAttrib .
Example: var topRowAttrib = 'style="background-color: blue"'; will give the top row a blue background
var bottomRowAttrib = '';

(see below for layout)
For the bottom row with the contribution numbers.
Example: var bottomRowAttrib = 'style="background-color: white; font-size: large"'; will give the bottom row a white background and slightly larger text
var dateFormat = ''; Formats the timestamp at the bottom of the table (and in the date subpage if enabled). More information on how to format the date can be found on the extension's documentation page.
Example: var dateFormat = 'F j, Y'; will give September 4, 2020
F j, Y
var noInclude = ''; Places something onto the page(s) at the very end without having it come through the transclusion. noInclude by itself will place whatever you set it to on all three pages. Placing a 1, 2, or 3 at the end will place it in the main count page, date page, or total page respectively.
Example: var noInclude3 = ' cookies'; will put the word "cookies" in your total count page, spaced after your count.

Example table layout[edit]

{| mainTableAttrib
| tableCaption
|- topRowAttrib
namespace !! namespace etc.   (if tableHeaders=false: | namespace || namespace etc.)
|- bottomRowAttrib


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 {{User:Your name/edit count}} 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 var subPages is set to true, this script creates/edits three pages at a time, so please use it sparingly to avoid recent changes spam.


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

Count discrepancy[edit]

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.


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
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, 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'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 and especially 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.