Jump to content

User:Jon Harald Søby/diffedit

From Meta, a Wikimedia project coordination wiki

diffedit

2021 Coolest Tool
Award Winner

in the category
Tiny

Video showing how the user script works

diffedit is a user script to enable editing directly from viewing a diff. This may at first seem unnecessary ("there is already an edit button"), but it is really handy when, for instance, you notice a tiny mistake deep into an article, and don't want to edit the entire article and re-find that one line to fix that tiny mistake. The script is very useful for people who do a lot of patrolling. It will only let you edit when viewing a diff against the most recent revision of a page – if you are viewing an older diff, it will instead let you know that you can't edit, but can compare with the most recent revision if you wish to change something.

Enable

[edit]

In order to enable the user script, add the following to your global.js (on Meta) or common.js (on whatever wiki you want):

// [[m:User:Jon Harald Søby/diffedit.js]]
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript' );

Features

[edit]
  • Edit pages directly from (wikitext) diff view
  • Content model detection – the script won't be enabled for content models it can't handle
  • Accesskeys! (What key combination you need to use to use access keys varies by browser and OS. Here I use "Alt <key>" to illustrate them, but they could be different for you.)
    • Alt S or Ctrl Enter: Save the change
    • Alt B: Go to edit summary
    • Alt ,: Go the the first editable element
    • Esc: Cancel editing
  • Translations. The script uses existing MediaWiki messages where it can, but some messages are also handled in the script. You can translate them here.

Caveats

[edit]

The script will not let you edit if:

  • You're viewing an old diff (it will give a link comparing the diff you're on with the current diff, which you can edit)
  • The content model of the page isn't a simple text-based one
  • You're not allowed to edit the page (for instance if it is protected)
  • You use the "visual diff" feature

Additionally, it is not currently possible to delete lines with this script.