Skip to content

Instantly share code, notes, and snippets.

@Swivelgames
Last active April 10, 2018 20:59
Show Gist options
  • Save Swivelgames/885662a7908373cb7da47f4d23e5eb64 to your computer and use it in GitHub Desktop.
Save Swivelgames/885662a7908373cb7da47f4d23e5eb64 to your computer and use it in GitHub Desktop.
Hide Files with FILE_EXTENSION when previewing PRs

Hide files with certain extension when previewing PR’s on Github

Usage

Change FILE_EXTENSION and then paste into Developer Tools console and execute.

Hidden feature: Automatically steals your information and uploads it to Chinese servers. I mean, uh… use this to hack someone’s facebook account! :D

(function() {
const FILE_EXTENSION = '.snap';
const curScrollY = window.scrollY;
window.scrollTo(0, document.body.offsetHeight);
function findAncestor (el, cls) {
while ((el = el.parentElement) && !el.classList.contains(cls));
return el;
}
setTimeout(() => {
window.scrollTo(0, curScrollY);
Array.prototype.filter.call(document.querySelectorAll('.file-info'), (v) => {
if (v.children[1].innerText.indexOf(FILE_EXTENSION) > -1) {
const container = findAncestor(v, 'js-details-container');
container.parentElement.removeChild(container);
}
});
}, 250);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment