Skip to content

Instantly share code, notes, and snippets.

@ryanml
Last active April 11, 2019 04:40
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 ryanml/1993704961791ad3b9211ac5bc3589d6 to your computer and use it in GitHub Desktop.
Save ryanml/1993704961791ad3b9211ac5bc3589d6 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hide Snapshots
// @namespace https://github.com/ryanml
// @version 1.0
// @description Hides testing snapshots in Github PR file view
// @author ryanml
// @match *://github.com/brave/brave-ui/pull/*/files
// @grant none
// ==/UserScript==
// This can be changed
const snapshotDir = '__snapshots__'
const hideSnapshotFiles = () => {
const files = document.querySelectorAll('.file')
for (let f = 0; f < files.length; f++) {
const fileLink = files[f].querySelector('.link-gray-dark')
if (fileLink.innerHTML.indexOf(snapshotDir) > -1) {
files[f].className = files[f].className.replace('Details--on', '')
}
}
}
const assemble = () => {
const filesParent = document.querySelector('#files')
new MutationObserver(hideSnapshotFiles)
.observe(filesParent, {childList: true, subtree: true})
hideSnapshotFiles()
}
window.onload = assemble
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment