Jump to content

User:Technical 13/Scripts/Gadget-pageCount.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* show result count if all results are shown on one page */
if ( $( 'div#mw-content-text' ).html().search( /previous [\d,]* \|  next [\d,]*/ ) !== -1 ) {
   var allPagesReplace = 'showing ';
    if ( $( 'ul#mw-whatlinkshere-list li' ).length === 1 ) {
        allPagesReplace += 'the only ';
    } else if ( $( 'ul#mw-whatlinkshere-list li' ).length > 1 ) {
        allPagesReplace += 'all ' + $( 'ul#mw-whatlinkshere-list li' ).length;
    }
    allPagesReplace += ' result';
    if ( $('ul#mw-whatlinkshere-list li' ).length > 1 ) {
        allPagesReplace += 's';
    }
   $( 'div#mw-content-text' ).html( $( 'div#mw-content-text' ).html().replace( /previous [\d,]* \|  next [\d,]*/g, allPagesReplace ) );
}