Last active
February 3, 2021 19:38
-
-
Save davatron5000/9db6a622a6f2203ec1f900512d6fae86 to your computer and use it in GitHub Desktop.
This file contains 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
document.querySelectorAll('.Box-row .js-navigation-open').forEach( (item) => { | |
const filename = item.textContent.toLowerCase(); | |
const humanFiles = ['AUTHORS', 'CHANGELOG', 'CODE_OF_CONDUCT', 'CONTRIBUTING', 'LICENSE', 'README', 'TECHNOLOGY', 'TROUBLESHOOTING', 'SECURITY']; | |
const row = item.parentNode.parentNode.parentNode; | |
if((filename != 'src' && filename.endsWith('rc')) | |
|| filename.includes('config') | |
|| filename.includes('ignore') | |
|| filename.includes('.conf.js') | |
|| filename.includes('webpack') | |
|| filename == 'robots.txt' | |
|| filename == 'sitemap.xml' | |
|| filename == 'cname' | |
|| filename.endsWith('.toml') | |
|| filename.endsWith('.json') | |
|| filename.endsWith('.json5') | |
|| filename.endsWith('.yml') | |
|| filename.endsWith('.yaml') | |
|| filename.endsWith('.lock') | |
|| filename.endsWith('-lock.json') | |
|| filename.endsWith('.bazel') | |
|| filename.startsWith('gemfile') | |
|| filename.startsWith('gruntfile') | |
|| filename.startsWith('gulpfile') | |
|| filename.startsWith('.') | |
){ | |
row.style.background = '#fee9e8' | |
} else if(humanFiles.includes(item.textContent.split('-')[0].split('.')[0])) { | |
row.style.background = '#edf6fd' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A couple quick suggestions based on a few repos I looked at:
item.textContent.endsWith('.json5')
I did not know this, but apparently json5 is a thing and is in the Gatsy repo for a dependency management tool.
item.textContent.endsWith('.yml')
item.textContent.endsWith('.yaml')
Because, you know, more ways to config.
item.textContent.endsWith('.lock')
item.textContent.endsWith('-lock.json')
Those would both catch
yarn.lock
andpackage-lock.json
item.textContent.endsWith('.bazel')
Never used it, but seen it on projects.
item.textContent.includes('.conf.js')
Another pattern I've seen.
item.textContent.includes('webpack')
Because I've seen webpack have "base configs" which get named like
webpackBaseConfig.js
Other
Maybe set
item.textContent
to a var name and do.toLowerCase()
because it'll catchgulpfile.js
but notGulpfile.js
.