Jump to content

User:PerfektesChaos/js/redirectResolver

From Wikipedia, the free encyclopedia

JavaScript gadget – explain target of redirect links and replace redirect page on source editing.

Please note that there are cases where it is better to keep the current link pointing to a redirect page since that target might be replaced by an advanced page in the future, or the final target might be updated.

Usage

[edit]
  • If your project has registered this as a gadget, just activate on your Preferences page.
  • Otherwise include the following line into your common.js, global.js etc.:
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/redirectResolver/r.js&action=raw&maxage=86400&ctype=text/javascript" );

Functionality

[edit]

On a rendered wikitext page, MediaWiki will equip with class mw-redirect all internal links pointing to a redirect page. Within rendered content will be appended to such links.

It is a button, opening a tiny popup.

To close that popup, click this button again, or click another similar button, or click X within the popup.

[edit]
  1. Wikipedia:SC
  2. Wikipedia:Shortcut
  • X
  • Wikipedia:SC
    • Link target in effect on rendered page.
    • Pointing here to redirect page without automatic forwarding (redirect=no).
    • Will be opened in a new browser tab/window.
  • Wikipedia:Shortcut
    • Target of redirect.
    • Might appear after short delay, since MediaWiki server could need time to answer.
Symbols
X Close
1.3 Version number
  • Pointing to this page here, or translation.
  • Will be opened in a new browser tab/window.
Exchange this link in source text
... Exchanging …
3 Number of successful changes, if any
0 No successful change

Exchanging

[edit]

On source text editing, exchanging will be done on regular wikitext in double brackets [[ (may be titled with pipe |) and most usual syntax.

Templates, comments and any <> will prevent this particular link from changing.

Exchanging is in effect for syntax disabled by <!-- --> comments or <nowiki> <pre> <syntaxhighlight> elements.

Opening but not closed [[ might hide a clickable link within.

Template parameter values cannot be identified as page names of a redirect page, nor results of template transclusion.

Please check via diff page whether result is matching your expectations.

Individual Configuration

[edit]

CSS

[edit]

All relevant elements have selectors prefixed by gadget-redirectresolver and may be subject to personal adaptions.

The following definition for class mw-redirect will give a pink background to all redirect links and this tool.

.mw-redirect {
   background-color: #FFC0CB ! important;
}

One common specification for redirect links only is this one:

a.mw-redirect {
   background-color: #F0E68C;
}

Internationalization

[edit]

A translation of this page may be offered.

Codes

[edit]
Source code
ResourceLoader
  • ext.gadget.redirectResolver for mw:Extension:Gadgets
  • Dependencies:
    • None required (self-completing)
    • It may be offered, since expected on all wikitext pages:
      • mediawiki.Title
      • mediawiki.util
Namespaces all
Actions all
mw.libs redirectResolver (reserved, but currently unused)
mw.hook
  • redirectResolver.ready
    When code has been loaded.
    Tells implementation metadata.
MediaWiki MW 1.22
JavaScript 1.5 (2000)