Last active
May 31, 2016 15:30
-
-
Save stevenschobert/96c92c101dcef910ad01c448314fcc81 to your computer and use it in GitHub Desktop.
Hide certain files in a GitHub diff based on file path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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