Jump to content

User:Aram/diff restorer

From Wikipedia, the free encyclopedia
diff restorer
diff restorer active in the diff view, displaying restore and success icons.
DescriptionEffortlessly restore deleted lines while editing and viewing changes.
Author(s)Aram
StatusExperimental
First releasedFebruary 24, 2025; 21 days ago (2025-02-24)
Version1.0.3
UpdatedFebruary 14, 2025; 31 days ago (2025-02-14)
Browsersalmost all (but not tested on all)
Skinsall
SourceUser:Aram/diff restorer.js

diff restorer makes it easy to restore deleted lines and delete added lines in the diff view while editing without manual find-and-replace or copy-pasting. Simply click the button (or for RTL projects) next to a deleted line to instantly restore its content into the edit box.

Installation

[edit]

To install diff restorer on English Wikipedia, add the following line to your common.js:

importScript('User:Aram/diff restorer.js'); // Backlink: [[User:Aram/diff restorer.js]]

For all projects, add the following to your your global.js (on Metawiki):

// [[:en:User:Aram/diff restorer.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Aram/diff_restorer.js&action=raw&ctype=text/javascript' );

Usage

[edit]

After installing, edit any page by deleting, adding or modifying some text. Then, click Show changes or press Alt+⇧ Shift+v to view the differences.

If a deleted, added or replaced line appears in the diff, you’ll see (or for RTL projects) next to it. Each line has its own restore button.

Clicking a button will display for successful restorations or for failed ones. The script can detect moved paragraphs, restore their contents and move back them to their original position they were before.

Notes

[edit]
  • diff restorer is a newly created script, introduced on February 14, 2025. It is an experimental user script, so use it at your own risk.
  • Important: You cannot use Ctrl+Z to undo or Ctrl+Y to redo changes while using this script.
  • Currently, the script has only been tested with the wikitext editor. If you're editing modules or other code pages, ensure you're not using the code editor.
  • This script is a significant time-saver, especially for users who frequently updating templates, modules and other tools. When comparing a new version with their existing one, they may encounter numerous lines where only the original strings have been reverted without actual code changes. With diff restorer, these strings can be quickly restored.
  • (If you have time to read) The story behind this script:
    • I personally faced this issue and spent a lot of time manually restoring our strings. After searching for a free tool, I found Meld which is a good solution and worked for me.
    • Initially, I considered submitting a feature request on Phabricator, but based on past experiences, I wasn’t optimistic about the outcome. Instead, I decided to develop diff restorer.
    • In traditional software, this process is known as "merging" since it involves comparing two files. However, since we only have a single text area in this case, I named it diff restorer, even if it's not the perfect title.

See Also

[edit]