DiffUndo
DescriptionPartially undo changes by double-clicking on a diff
UpdatedSeptember 7, 2024
    (4 days ago)
Browser supportChrome, Firefox, etc. (ES2020+ needed)
SourceUser:Nardog/DiffUndo.js

This script allows you to undo your changes line by line by double-clicking on a diff while editing ("Show changes"). Though inspired by a similar feature in AutoWikiBrowser, it also allows you to redo an undone change by double-clicking the line again.

It comes in handy especially when reverting edits. If you want to revert only part of an edit, you can click "undo" and keep certain changes by double-clicking on the diff. If you want to revert an old edit but MediaWiki's native undo feature doesn't work because later edits interfere, you can go to the editing page of the previous revision, click "Show changes", and restore all the non-problematic edits by double-clicking the lines.

Installation

edit

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

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Nardog/DiffUndo.js&action=raw&ctype=text/javascript');

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

How it works

edit

You can undo a change as long as the line in the current source (deduced from the closest line number on the diff) matches the line in the "Your text" column of the diff. In case of a removed line (i.e. the cell in the "Your text" column is empty), the preceding line is compared. A redo works just like that except the columns are reversed.

You can also use ↵ Enter/Return instead of double-clicking.

Limitations

edit
  • Undoing a change may clear the browser's native undo cache (Ctrl+Z).
  • If syntax highlighting (CodeMirror) is on, the browser scrolls to the edit box on each undo.
  • VisualEditor and the 2017 wikitext editor are not supported.