User:Frietjes/findargdups

Why does this script exist?
Pages transcluding templates called with duplicate arguments are listed in Category:Pages using duplicate arguments in template calls. Examples of duplicate arguments are  or   This script assists editors with finding the duplicate arguments within a particular page.

How to install
To install on another Wikipedia, use
 * 1) Open your common.js script page in edit mode.
 * 2) Paste the following line:
 * 3) Reload the script page (press   or the equivalent for your browser).

How to use

 * 1) Find a page with duplicate arguments in Category:Pages using duplicate arguments in template calls.
 * 2) Open the page in edit mode, and press "Show preview" without making any changes.
 * 3) Look for the following message at the top of the page:
 * 4) * If the above warning does not appear at all, then the problem has already been fixed. Save the page without making any edits to force the server to re-process the page to remove it from the category.
 * 5) * If the text in place of "$1" in the above warning is a link to a template, then the problem lies in that template. Open that template in edit mode and continue with the next step.
 * 6) * If the text in place of "$1" in the above warning is a self-link (i.e., the page's own name in bold), then continue with the next step.
 * 7) Select the   link in the   section on the left side of the page.
 * 8) If duplicate template arguments were found by the script, you will see an alert popup telling you where to look.
 * 9) Fix the problem, and save the page.  The script will create an edit summary for you.

Caveats
If the warning message appears for the page you are currently editing, but the script fails to provide a popup, then you have encountered a case not considered by the script's author, or a bug, and you should report this on the talk page so it can be fixed (or a reason can be given for not fixing it).

Technical details
For editors interested in better understanding how the script works, the following is a general overview of how it works. The script does the following:


 * 1) Copies the contents of the edit window to a local string
 * 2) Removes triple brace enclosed template variables, like.
 * 3) Replaces braces not preceded or followed by a brace with the HTML equivalent.
 * 4) Replaces all carriage returns and newlines and tabs with spaces, and replace duplicate spaces with a single space.
 * 5) Splits   into an array of strings where the split points are any double braces.
 * 6) Loops through the array of strings, pulling out unnested templates and pushing them into an array of strings called  .  This step is performed repeatedly (up to 10 times) to try to unnest all the templates on the page.
 * 7) Loops through the list of unnested templates
 * 8) Inserts equivalent numeric arguments for any unnamed arguments for each template in.
 * 9) Sorts the template arguments
 * 10) Issues an alert popup for any duplicate arguments
 * 11) If any duplicates were found, changes the edit summary to a useful default.

Changing the default edit summary
To change the default edit summary, define  in your common.js script page before the script is imported. For example, To disable this feature, use an empty string.

Adding an additional results box
On some browsers, like Google Chrome, the text in the alert box cannot be copied/selected for searching. To add an additional results box with selectable text, define  in your common.js script page before the script is imported. For example,

Bubble notification when no duplicates are found
By default, the script issues a bubble notification when no duplicates are found. If you would like to change this message, define  in your common.js script page before the script is imported. For example, To disable this message, define  to be an empty string

Translating messages and link text
To change the default messages and link text, define,  ,  , and   in your common.js script page before the script is imported. For example, for French, or for Latvian