User:Ohconfucius/script/flagcruft

Preamble
This tool was developed for my own personal use to speedily removing swathes of abused icons, it may help you to pare back extreme instances of over reliance on flags in a single manipulation.

By long-standing convention and as detailed at the Manual of Style, a Wikipedia article needs to use consistent formatting. Despite there being long standing guidelines as to their use, flag icons are much abused within Wikipedia. Users, particularly in sporting and political fields, are wont to plaster certain articles with so many tiny flag icons that it's difficult to make sense of which country they are meant to refer to, or what they mean.
 * Within-article consistency of formatting


 * There is, for example, no benefit to using flags (and flags only) to give the location of a stadium where a match was played, as was done here, or where a tournament was hosted, as here.
 * Using flags for team managers' nationalities (as here and here) is irrelevant at best.

Caveat

 * The script should be used with care. Its use may provoke ire or controversy because many editors seem anchored to the aesthetic appeal of those coloured rectangles dotted all over a page and the security that these may impart. Some cite familiarity with flag use on some external websites and seeking to apply them here.


 * It may not be appropriate to simply sweep away all flag icons, some icons may need to be replaced with the country name. Thus there are instances where different sections of an article may require separate treatment, or the use of the two script buttons in different combinations (see this series of edits).

Functions
Functions performed include:
 * remove bare flag images, denoted by the syntax " [[File:Flag of Country.svg|[23]px... " or " [[Image:Flag of Country.svg|[23]px... ", and trailing space (if any)
 * Removes flag icons that rely on the flagicon template
 * Replaces flag icons with the corresponding country name without wikilink
 * Where required, the script will decode the ISO 3166-1 alpha-3 associated with the flag (and most commonly used 3-lettered abbreviations) and give the country name.

Actions
Once you are in edit mode, there is a button in the toolbox in the left margin
 * FLAGCRUFT function – Removes flag icons and blanks icons called by the nat or clubnat parameters within certain templates.
 * FLAG->COUNTRY function – Removes flag icons, replaces with the corresponding country name without wikilink.

Miniature flag icons called by other sporting templates that link to national sporting/team articles should not be affected

Bug reports
Feedback is appreciated at User talk:Ohconfucius/script. Please report false negatives as well as false positives.

Essays

 * Flags are being seriously abused on Wikipedia