GitHub Remove Diff Signs

A userscript that removes the "+" and "-" from code diffs

As of 14.04.2017. See ბოლო ვერსია.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        GitHub Remove Diff Signs
// @version     1.1.3
// @description A userscript that removes the "+" and "-" from code diffs
// @license     https://creativecommons.org/licenses/by-sa/4.0/
// @author      Rob Garrison
// @namespace   https://github.com/Mottie
// @include     https://github.com/*
// @run-at      document-idle
// @grant       none
// @require     https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=188072
// @icon        https://github.com/fluidicon.png
// ==/UserScript==
(() => {
	"use strict";

	function processDiff() {
		if (document.querySelector(".highlight")) {
			let indx = 0,

				els = document.querySelectorAll(`
					.blob-code-deletion .blob-code-inner,
					.blob-code-addition .blob-code-inner`
				),
				len = els.length,

				// target "+" and "-" at start
				regex = /^[+-]/,

				// loop with delay to allow user interaction
				loop = () => {
					let el, txt,
						// max number of DOM insertions per loop
						max = 0;
					while ( max < 50 && indx < len ) {
						if (indx >= len) {
							return;
						}
						el = els[indx];
						txt = el.childNodes[0].textContent;
						el.childNodes[0].textContent = txt.replace(regex, " ");
						max++;
						indx++;
					}
					if (indx < len) {
						setTimeout(() => {
							loop();
						}, 200);
					}
				};
			loop();
		}
	}

	// Observe GitHub dynamic content
	document.addEventListener("ghmo:container", init);
	document.addEventListener("ghmo:diff", processDiff);

	function init() {
		if (document.querySelector("#files.diff-view")) {
			processDiff();
		}
	}

	init();

})();