Skip to content

Instantly share code, notes, and snippets.

@stevenschobert
Last active May 31, 2016 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenschobert/96c92c101dcef910ad01c448314fcc81 to your computer and use it in GitHub Desktop.
Save stevenschobert/96c92c101dcef910ad01c448314fcc81 to your computer and use it in GitHub Desktop.
Hide certain files in a GitHub diff based on file path.
function hideNodes(matcher) {
var fileNodes = document.querySelectorAll("#files .file");
var indeciesToHide = [];
var tester = (typeof matcher === "string") ? new RegExp(matcher) : matcher;
var fileHeader;
var filePath;
for (var i=0; i < fileNodes.length; i++) {
fileHeader = null;
filePath = null;
fileHeader = fileNodes[i].querySelector(".file-header");
if (fileHeader) {
filePath = fileHeader.getAttribute("data-path");
if (fileHeader && tester.test(filePath)) {
indeciesToHide.push(i);
}
}
}
for (var j=0; j < indeciesToHide.length; j++) {
fileNodes[j].setAttribute("style", "display: none;")
}
}
// example usage
hideNodes(/^Pods\/.*/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment