Skip to content

Instantly share code, notes, and snippets.

@WebReflection
Created December 5, 2017 11:03
Show Gist options
  • Save WebReflection/4030f0d016a7038f03ecfef58b2cc955 to your computer and use it in GitHub Desktop.
Save WebReflection/4030f0d016a7038f03ecfef58b2cc955 to your computer and use it in GitHub Desktop.
function removeColumn($0) {
let tr = $0.closest('tr');
const index = [].indexOf.call(tr.querySelectorAll($0.nodeName), $0);
$0.remove();
tr = tr.closest('thead').nextElementSibling.querySelector('tr');
do {
let td = tr.querySelectorAll('td');
if (td.length) td[index - 1].remove();
else tr.querySelectorAll('th')[index].remove();
} while (tr = tr.nextElementSibling);
}
const table = document.querySelectorAll('table');
table[0].querySelectorAll('thead th').forEach((th, i) => {
if (i && !/hyperhtml|preact|vue |vanillajs/.test(th.textContent)) removeColumn(th);
});
table[0].insertBefore(document.createElement('caption'), table[0].firstChild).textContent = 'Duration in milliseconds (Slowdown = Duration / Fastest)';
table[1].querySelectorAll('thead th').forEach((th, i) => {
if (i && !/hyperhtml|preact|vue |vanillajs/.test(th.textContent)) removeColumn(th);
});
table[1].insertBefore(document.createElement('caption'), table[1].firstChild).textContent = 'Memory allocation in MBs';
table.forEach(table => {
table.style.float = 'left';
table.style.marginLeft = '20px';
});
document.querySelectorAll('h1, h2, h3, p').forEach(node => node.remove());
table[2].remove();
table[3].remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment