User:Nardog/DiffFontSwitcher.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
(mw.config.exists('wgDiffNewId') || mw.config.get('wgAction') !== 'view' ||
mw.config.get('wgNamespaceNumber') === -1) &&
(function diffFontSwitcher() {
	mw.loader.addStyleTag('.diff-lineno{cursor:pointer}');
	$(document.body).on('click keydown', '.diff-lineno', function (e) {
		if (e.type === 'keydown' &&
			(e.which !== 13 && e.which !== 32 || e.ctrlKey || e.shiftKey || e.metaKey || e.altKey)
		) {
			return;
		}
		e.preventDefault();
		this.closest('.diff').classList.toggle('difffontswitcher-enabled');
	});
	mw.hook('wikipage.diff').add($diff => {
		$diff.find('.diff-lineno').attr({
			tabindex: 0,
			role: 'button'
		});
	});
})();