User:Kanegasi
/editcounter
Appearance
| This script is licensed under the Creative Commons Attribution-ShareAlike 3.0 License. This script can be freely used on this wiki and users can use, download and edit this script provided that credit is attributed to the original author. Derivative works must be licensed using the same or similar license. |
|
|
Description
[edit]- 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 ( 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:
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.
|
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. |
false |
var datePageName = '';
|
Sets the name of the page where the last date counted is placed.
|
edit count/date |
var totalPageName = '';
|
Sets the name of the page where the total count number is placed.
|
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.
|
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.
|
Normal names |
var mainTableAttrib = ''; (see below for layout) |
Whole table attributes, such as cellpadding, cellspacing, class="wikitable" , and the style="" options.
|
class="wikitable" 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 .
|
None |
var bottomRowAttrib = ''; (see below for layout) |
For the bottom row with the contribution numbers.
|
None |
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.
|
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.
|
None |
Example table layout
[edit]
{| mainTableAttrib
namespace
|-
| tableCaption
|- topRowAttrib
! !!
namespace etc. (if tableHeaders=false: |
namespace ||
namespace etc.)
numbers
|- bottomRowAttrib
|
|}
Usage
[edit]- 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 totrue
, this script creates/edits three pages at a time, so please use it sparingly to avoid recent changes spam.
Bugs
[edit]- 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.
Credits
[edit]- 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.