This script adds an undo button to each line on the diff between the current version of the page and yours while editing ("Show changes"). Though inspired by a similar feature in AutoWikiBrowser, it also allows you to redo an undone change by clicking the button again.
It comes in handy especially when reverting edits. If you want to revert only part of an edit, you can click "undo" on page history or a diff and keep certain changes by undoing 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 undoing the lines.
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.