Skip to content

Instantly share code, notes, and snippets.

@ibolmo
Created December 9, 2016 18:48
Show Gist options
  • Save ibolmo/1d95145e1ba5aef46a34bbe0e83b7a17 to your computer and use it in GitHub Desktop.
Save ibolmo/1d95145e1ba5aef46a34bbe0e83b7a17 to your computer and use it in GitHub Desktop.
Adds filtering of node.green results. Append ?max=4 to url. Uses: https://github.com/defunkt/dotjs
const get = (url, key) => {
const a = document.createElement('a');
a.href = url;
if (!a.search) return null;
const regex = new RegExp(key, 'i');
return a.search.split('&').filter(regex.test, regex)[0].split('=')[1];
}
const max = get(location.href, 'max');
if (max) {
const permitted = [];
[...document.querySelectorAll('th')].forEach((th, i) => {
if (th.classList.contains(`v${4}`)) {
permitted.push(i);
th.style.display = 'table-cell';
}
});
document.head.innerHTML += `
<style>
th, .result {
display: none;
}
${permitted.map(i => `.result:nth-child(${i + 1})`).join(', ')} {
display: table-cell;
}
</style>
`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment