User:Cameltrader/Advisor.js/Description

I developed a custom script which suggests one-click fixes for repetitive mistakes when editing an article. Due to limited interest, I only do minor fixes. The tool proves helpful every now and then (I'm eating my own dog food), so I decided to keep this description.

Installation
Add this to your monobook.js:  User:Cameltrader/Advisor.js 



Then refresh. From now on, a list of suggestions will appear above your edit box, while you are editing a page. Click on the suggestion name to highlight the text it refers to; click on the "fix" superscript next to it, to get it into shape.

If you are suspicious about things you add to your monobook.js, and suspicious you should be, review the code before using it.

Implemented rules
A rule is a piece of code which produces suggestions:


 * lang-xx: Think of xx as an alpha2 code. These templates are used to describe a certain piece of text as written in a foreign language. For instance:
 * becomes
 * becomes


 * heading: Fixes displaced space characters, allows only  or   (I, personally, prefer the first one), and may correct the spelling and capitalizations of standard headings, such as "External links", "References", "See also". Improper nesting of headings is reported, too.
 * becomes
 * becomes


 * A|A: This is to say that  is equivalent to.
 * becomes
 * becomes


 * A|AB: If "B" is a word ending,  can be simplified to.
 * becomes
 * becomes


 * ndash for year ranges: My script prefers the Unicode character when suggesting a replacement, but it doesn't attempt to modify existing HTML escapes . This rule doesn't (yet) catch "circa" year ranges, like " "
 * becomes
 * becomes


 * cat-sort: If the article name looks like a person's name, then make sure that the sort key for the categories is the last name. Exceptions can be specified in the script. Most Bulgarian, Macedonian, Russian, and similar names are easy to recognize because of the -ov, -ev, or -ski endings. If you have a suggestion for recognizing names of persons in your language, let me know. For instance, in an article named "Georgi Markov":
 * becomes
 * becomes


 * default-sort (introduced instead of "cat-sort"): If the article name looks like a person's name, and it is used as a sort key for some category, then suggest using the "DEFAULTSORT" magic word. Exceptions can be specified in the script. Most Bulgarian, Macedonian, Russian, and similar names are easy to recognize because of the -ov, -ev, or -ski endings. If you have a suggestion for recognizing names of persons in your language, let me know. For instance, in an article named "Georgi Markov":
 * becomes
 * becomes
 * becomes


 * year link: Year links which are not preceded by a date are of no use and should be suggested for removal.
 * becomes
 * becomes


 * main-article, further, ...: Suggest using templates for standard pieces of text, such as this:
 * becomes
 * becomes

Proposed rules
These are not yet in, but are worth considering:


 * ipa: Sequences of IPA characters should be enclosed like this &mdash;, in order to let MediaWiki add browser quirks.


 *  : Mediawiki's syntax allows rewriting this as . The namespace and the text in brackets are optional. (This is known as the pipe trick, and   is restored to   when you save the page. So, it doesn't make sense to suggest replacing it...)


 * heading-bias: If spaced headings in the article are decisively more than unspaced headings, or vice versa, suggest conforming to the majority.


 * AmE-BrE-bias: same for American English vs British English.


 * date-bias: same for American-style dates (" January 1, 2000 "), some other parts of the world use it, too) vs conventional dates (" 1 January 2000 "). I believe the topic of the article (e. g. if it is related to the US) should influence the balance, if there's a good heuristic to recognize Americanisms.


 * as-of, as-of-month: Suggest linking of " as of 2000 " as " as of 2000 ", and converting " as of January 2000 " to " as of January 2000 " per WP:AO.


 * Your proposal here.


 * lang|bg: Suspiciously-looking sequences of Cyrillic characters can be marked with, if they are in Bulgarian. This has no effect on the way it looks in a browser, but may help tools identify foreign texts. Note, that many languages use the Cyrillic alphabet, so it may not be Bulgarian. (I may need to remove this rule at some point.)

Known issues

 * May behave strangely in Internet Exporer. Automatic selection of suspicious text doesn't work, and there could be more issues. My policy is to be compatible with Internet Explorer, so I'll be working on that.


 * Clicking on a suggestion link sometimes fails to transfer focus to the editing textarea. I observed this behaviour in Firefox and Galeon. A simple workaround is to press "tab" to get the focus right.


 * After clicking "Preview", the proposed summary is lost. In other words: you edit a page, you "fix" some of the suggestions on top, the names of the changes get accumulated and appear with an "Add to summary" link just above the "Edit summary" line, then you click "Preview" (without clicking "Add to summary"), and your accumulated names of changes disappear, so you have to go back. It's a usability issue.


 * Your issue here.


 * The code which scrolls to the selected text in the textarea was adapted from Zocky's Searchbox script, and therefore has the scrolling issue: "The found text may sometimes still be outside the edit box. Scroll up and down a bit to find it.".


 * Advisor.js relies on the presence of the edit toolbar, so it doesn't work when it the toolbar is switched off from the user preferences. The toolbar is present by default, and most Wikipedians seem to use it. However, this dependency is not really required, and Advisor.js</tt> can be changed accordingly.