GitHub Remove Diff Signs

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

2018-04-09 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        GitHub Remove Diff Signs
// @version     1.2.2
// @description A userscript that removes the "+" and "-" from code diffs
// @license     MIT
// @author      Rob Garrison
// @namespace   https://github.com/Mottie
// @include     https://github.com/*
// @run-at      document-idle
// @grant       GM_addStyle
// @require     https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=264157
// @icon        https://assets-cdn.github.com/pinned-octocat.svg
// ==/UserScript==
(() => {
	"use strict";

	GM_addStyle(`.diff-table .blob-code-inner:before {
		user-select: none;
		content: "\\a0";
	}`);

	function processDiff() {
		if (document.querySelector(".highlight")) {
			let indx = 0,
				els = document.querySelectorAll(`span.blob-code-inner:not([data-ghrds])`),
				len = els.length;

			// loop with delay to allow user interaction
			function loop() {
				let el, txt, firstNode,
					// max number of DOM insertions per loop
					max = 0;
				while ( max < 50 && indx < len ) {
					if (indx >= len) {
						return;
					}
					el = els[indx];
					if (!el.getAttribute("data-ghrds")) {
						firstNode = el.childNodes[0];
						txt = firstNode.textContent || "";
						// remove the leading +, - or first space
						// the github-code-show-whitespace.user.js script is applied
						firstNode.textContent = txt.slice(1);
						el.setAttribute("data-ghrds", true);
					}
					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();

})();