User:Kephir/gadgets/unclutter

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Unclutter
Keφr's Unclutter.png
Author Keφr
Status Semi-stable
Updated 2013-09-22
Browser support
  • Developed on Chromium
Skin support
  • Tested mostly on Vector
  • No issues noticed on Modern and Monobook
Source
If all displayed information is important, important information is easy to find.

Ken Arnold, quoted by Eric Raymond in chapter 1 of The Art of Unix Programming

Unclutter helps in freeing Wikipedia from distractions. It does so by hiding some of the editing hints, warnings, never-to-be-used helpers, policy reminders on talk pages and other unnecessary verbosity. It also adds hiding links to discussion headers and editnotices, wraps and minimises user signatures.

Warning: Enabling the stylesheet installed by Unclutter is not recommended for inexperienced editors, who might find the advice hidden by this script to be occasionally useful. Specifically, hiding messages reminding you of Wikipedia policies does NOT exempt you from these policies. New users may wish to install Unclutter with the stylesheet disabled by default, see the configuration section below.

Installation[edit]

Copy the following line into your common.js:

/* window.kephirUnclutter = { configuration } */
importScript('User:Kephir/gadgets/unclutter.js'); // [[User:Kephir/gadgets/unclutter]]

You may want to insert configuration options before importing the script; again, see the configuration section.

The CSS stylesheet will be pulled automatically from the page User:Kephir/gadgets/unclutter.css.

Non-Wikipedia installs[edit]

To install the script outside of Wikipedia, use this line instead of importScript:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Kephir/gadgets/unclutter.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');

Wikipedia-specific settings will not be activated. The CSS stylesheet will be pulled from the page User:Kephir/gadgets/unclutter.css on the local wiki, not from Wikipedia. Currently, only the English Wiktionary has a customised stylesheet; other wikis will have an empty sheet imported, which has no effect. Leave a note on the talk page if you want a stylesheet for your wiki.

Note: Unclutter is tested mostly on Wikipedia, which means it expects to run on a fairly recent version of MediaWiki. Compare Wikipedia's Special:Version page to your own wiki's before reporting problems.

Templates and interface affected[edit]

Items marked "heuristic" may be potentially incomplete or affect unexpected places, although the selectors have been chosen to be as specific as possible.

By the stylesheet[edit]

By JavaScript[edit]

  • Editnotices and editintros — made collapsible
  • Category and template list in the old editor — made collapsible, hidden by default
  • Discussions on talk pages and other discussion pages — made collapsible
  • Signatures — minimised

Importing the script will also add a "Toggle Unclutter" item to the toolbox. Clicking it will change whether the stylesheet affects the page.

Signature minimisation[edit]

Custom-styled Unclutter and Comments in Local Time reformatting signatures and timestamps in a Wikipedia discussion.

By default, Unclutter scans non-special non-article pages for timestamped signatures, wraps them up and replaces with a text of the form:

Example (annotation) (talkcontribactionslogsig)

The last link will show the original signature. In the section below, you can learn how to change the default behaviour; instead of completely hiding customised signatures, you might want to apply styles to specific users or groups (i.e. IP editors). Unclutter wraps signatures inside a span element and attaches CSS classes to them to allow this. When signature minimisation is disabled, this is the only thing Unclutter does.

kephir-unclutter-minisig
Attached to the minimised signature.
kephir-unclutter-signature-wrapper
Attached to the original signature.
signature
Attached to both of the above.
signature-username
Attached to signify whose signature it is. When referring to this class, some special characters may need to be escaped according to the CSS escaping rules.
ipv4
Attached to signatures of editors identified by an IPv4 address.
ipv6
Attached to signatures of editors identified by an IPv6 address.
unregistered
Attached to all signatures of unregistered editors.

The following classes are used in the minimised signature:

dash
The initial em-dash (—).
username
The user's name.
annotation
The username annotation, if any.
tlk-link
The talk page link.
ctb-link
The contributions page link.
act-link
The user's act link (for actions performed by this user).
log-link
The user's log link (for actions performed on this user).
sig-link
The "sig" link.

For example, to hide the log link, add this to your stylesheet:

.kephir-unclutter-minisig .log-link {
	display: none;
}

Configuration[edit]

To configure Unclutter, add the following code before importing the script:

window.kephirUnclutter = {
	enableOnPageLoad            : true,
	wrapDiscussions             : true,
	collapseDiscussionsByDefault: false,
	signaturesProcess           : true,
	signaturesMinimise          : true,
	signaturesColourise         : true,
	signaturesExceptions        : [],
	userAnnotations             : { /* "username": "annotation" pairs, separated by commas */ },
	processSig                  : function (context) { return false; },
	postProcessSig              : function (context) { return false; }
};

To set options, change values to the right of the colon. The values listed here are the defaults. Any line in the above code may be omitted, except for the first and the last. The last item should not end with a comma; this is a syntax error and will prevent the script from executing.

enableOnPageLoad
Whether to enable the stylesheet on page load. Inexperienced users should set this to false, otherwise nasty things may happen. At worst, a visit to Administrators' noticeboards. You have been warned.
wrapDiscussions
Whether to wrap discussions inside divs to make them collapsible. Disabling this might improve performance slightly, if you do not use this feature.
collapseDiscussionsByDefault
Whether previously unseen discussions should be collapsed or expanded by default. Previously seen discussions are left in the state they were last seen; HTML5 localStorage is used to remember it.
signaturesProcess
Determines whether to scan pages for signatures to process. Articles and special pages are never scanned. Only timestamped signatures are recognised, as non-timestamped signatures are too difficult to identify.
signaturesMinimise
Determines whether to minimise found signatures.
signaturesColourise
Determines whether Unclutter will set different background colours for signatures of different users.
signaturesExceptions
An array of names of users whose signatures are exempted from minimisation. Usernames should be written inside single or double quotes, separated by commas, like this: ["Example", 'Undefined']
userAnnotations
A braced list of username: annotation pairs, both enclosed within double or single quotes, separated by commas. The signature minimiser will attach the appropriate annotation to the username specified. For example: { "קיפודנחש": 'kipod' } (past default).
processSig
A JavaScript function which is called before minimisation and may return true to prevent Unclutter from performing it. The context is an object containing various information like the username, the DOM node of the minimised signature, etc. See the source code for details.
postProcessSig
A JavaScript function which is called after minimisation. context is the same as above.