User:Fred Gandt/moveFailedModuleTestsToTop.js

$( document ).ready( => {	"use strict";	if ( mw.config.get( "wgNamespaceNumber" ) == 829 ) {		// get all results tables		const ALL_RESULTS = Array.from( document.querySelectorAll( ".wikitable.unit-tests-result" ) );		if ( ALL_RESULTS.length ) {			console.log( "ALL_RESULTS: ", ALL_RESULTS );			// get contiguous blocks of result tables			const BLOCKS = [];			ALL_RESULTS.forEach( ( table, i ) => { if ( !~ALL_RESULTS.indexOf( table.nextElementSibling ) ) { BLOCKS.push( [ ...ALL_RESULTS.splice( 0, i + 1 ) ] ); }			} );			console.log( "BLOCKS: ", BLOCKS );			BLOCKS.forEach( block => { block.forEach( result => {					if ( result.querySelector( 'img[alt]:not([alt="check"])' ) ) {						block[ 0 ].before( result );					}				} ); } );		}	} } );