Skip to content

Instantly share code, notes, and snippets.

@alies-dev
Last active June 10, 2022 18:24
Show Gist options
  • Save alies-dev/23da264aee14a7efbc8d24f2f110a8d5 to your computer and use it in GitHub Desktop.
Save alies-dev/23da264aee14a7efbc8d24f2f110a8d5 to your computer and use it in GitHub Desktop.
GTMetrics comparison snippet
function returnRefinedURL(url) {
return url.replace(new RegExp("=\\w+"),"").replace("?&","?").replace("&&","&");
}
testsAndRequests = [];
document.querySelector('.report-waterfall').contentWindow.document.querySelectorAll('.vsc-initialized table .netTable').forEach((table, index) => {
table.querySelectorAll('.netFullHrefLabel.netHrefLabel.netLabel ').forEach((row, rowIndex) => {
if (rowIndex === 0) { testsAndRequests.push([]); }
testsAndRequests[index].push(row.textContent);
});
});
firstTestRequests = testsAndRequests[0].map(returnRefinedURL);
secondTestRequests = testsAndRequests[1].map(returnRefinedURL);
console.log('In A not in B: ', firstTestRequests.filter(x => !secondTestRequests.includes(x)));
console.log('In B not in A: ', secondTestRequests.filter(x => !firstTestRequests.includes(x)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment