User:Nardog/DiffUndo

This script adds an undo button to each line on the diff between the current and your versions of the page while editing ("Show changes"). Though inspired by a …

User:Nardog/DiffUndo
DiffUndo
DescriptionAdds an undo button to each line on the diff while editing
UpdatedOctober 9, 2024
    (22 months ago)
BrowsersChrome, Firefox, etc. (ES2020+ needed)
SourceUser:Nardog/DiffUndo.js

This script adds an undo button to each line on the diff between the current and your versions of the page 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. The button is visible only while the cursor or focus is inside a line.

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.

Installation

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

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.

Limitations

  • Lines involving pre-save transforms, such as {{subst:}} and signatures, cannot be undone.
  • Undoing a change may clear the browser's native undo cache (Ctrl+Z).
  • VisualEditor and the 2017 wikitext editor are not supported.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.