User:Rusalkii/previewRedirectContext

Preview redirect context
DescriptionShows a preview of the redirect in the target page, if it exists
UpdatedOctober 22, 2025
    (7 months ago)
SourceUser:Rusalkii/previewRedirectContext.js

This script searches for the redirect within the target page, and provides a preview of the first paragraph in which the first occurrence of the redirect can be found in the target, if it can be found at all. Primarily intended for new page patrollers.

To disable running by default on redirects, add `var autoRunRedirectContext = false` to your commons.js before the usercript. This should provide a button instead.

Installation

edit

Add the following to your common.js or global.js:

importScript('User:Rusalkii/previewRedirectContext.js'); // Backlink: [[User:Rusalkii/previewRedirectContext.js]]

Or you may enable the script installer in Preferences Gadgets and click "Install" in the infobox on this page.

Todo

edit

Feel free to add bugs or suggestions here (please sign unless you are secretly also Rusalkii):

  • fuzzier search: ignore punctuation, spacing
  • exclude infobox and other templates unless the search term is found in them?
  • when the redirect points to a section, search only that section (or that section first?)
  • option: preview lead as well as redirect context?
  • bug: fix text sometimes being removed with references
  • If the search term isn't found, then at least output the first x characters/lines of the page. Sometimes there is enough context there to approve the redirect. -MPGuy2824 (talk) 10:22, 4 February 2026 (UTC)

Limitations

edit
  • preview tries to trim out references so the text is readable, but it's not particularly good parsing and just looks for content between ref tags
  • finds only the first use of the term

Other redirect patrolling scripts

edit