User:Nardog/DiffFontSwitcher

DiffFontSwitcher
DescriptionToggle between fonts for diff by clicking on a line number
UpdatedJanuary 16, 2022
    (2 years ago)
BrowsersChrome, Firefox, etc.
SourceUser:Nardog/DiffFontSwitcher.js

Since May 2020, the font for editing is also used for diffs. Proportional and monospaced fonts each have advantages on diffs: the former may be more legible for longer texts, while the latter may make it easier to spot tiny differences such as punctuation. With this script, you can switch between the default font and a font of your choice by clicking on a line number ("Line n:") on any diff.

Usage

edit

If you prefer a monospaced font for editing but sans-serif for diffs, you can make sans-serif the default for diffs by adding the following to your common.css or global.css.

.diff .diff-addedline, .diff .diff-deletedline, .diff .diff-context {
	font-family: sans-serif;
}

And if you want to switch to a monospaced font by clicking on a line number on a diff, install the script by adding the following to your common.js or global.js:

mw.loader.load('//en.wiki.x.io/w/index.php?title=User:Nardog/DiffFontSwitcher.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.

And then add the following to the CSS:

.difffontswitcher-enabled .diff-addedline,
.difffontswitcher-enabled .diff-deletedline,
.difffontswitcher-enabled .diff-context {
	font-family: monospace;
}