Skip to content

Instantly share code, notes, and snippets.

@anevins12
Last active July 21, 2020 08:03
Show Gist options
  • Save anevins12/3057a188a0ad13ac19f479b4aa0a9c82 to your computer and use it in GitHub Desktop.
Save anevins12/3057a188a0ad13ac19f479b4aa0a9c82 to your computer and use it in GitHub Desktop.
Pa11y-ci Reporter custom filter
// Assumes jQuery is already defined on the page.
// Try a tampermonnkey script to define jQuery like this: https://gist.github.com/anevins12/e394718db5af815da397e6702d552c3a
(function() {
const invalidErrors = ['Set these yourself: Use the contents of the H2 element that is in the individal error page'];
const $listingErrors = $('.page');
$listingErrors.each(function() {
const $listingError = $(this);
const $listingErrorCount = $listingError.find('.counts .error');
const $link = $('.pageLink', $listingError);
$.ajax({
url: $link.attr('href'),
context: $(this),
async: false,
})
.done(function(data) {
const $dom = $(data);
const $errors = $('.error', $dom);
var errorCount = $errors.length;
// Set error index as though it was at 0.
errorCount--;
$.each($errors, function() {
const errorText = $('h2', this).text();
if (invalidErrors.includes(errorText)) {
errorCount = errorCount - 1;
$listingErrorCount.html(errorCount);
}
});
});
if ($listingErrorCount.text() === '0') {
$listingError.hide();
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment