Skip to content

Instantly share code, notes, and snippets.

@akuhn
Created April 27, 2017 13:06
Show Gist options
  • Save akuhn/29b40f29df481079f9a3453ab653845e to your computer and use it in GitHub Desktop.
Save akuhn/29b40f29df481079f9a3453ab653845e to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Github simplified diffs
// @namespace example
// @include https://git.musta.ch/*
// @include https://gist.git.musta.ch/*
// @include https://github.com/*
// @include https://gist.github.com/*
// @version 1.2
// @grant none
// ==/UserScript==
function simplify() {
function gsub(selector, regex) {
var nodes = document.querySelectorAll(selector);
for (var n = 0; n < nodes.length; n++) {
var children = nodes[n].childNodes;
for (var m = 0; m < children.length; m++) {
var text = children[m];
if (text.nodeType === 3) {
text.textContent = text.textContent.replace(regex, ' ');
break;
}
}
}
}
gsub('td.blob-code-addition span.blob-code-inner', /^\+/);
gsub('td.blob-code-deletion span.blob-code-inner', /^-/);
gsub('td.blob-code-addition', /^\+/);
gsub('td.blob-code-deletion', /^-/);
}
var token = null;
document.addEventListener(
"DOMNodeInserted",
function() { clearTimeout(token); token = setTimeout(simplify, 1); },
false
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment