User:ShakespeareFan00/pages.js
Appearance
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
Documentation for this script can be added at User:ShakespeareFan00/pages. |
/* fork from https://en.wikisource.org/w/index.php?title=User:Sohom_Datta/page-status-highlighter.js&oldid=13241938 to supress unproffread rows entirly.) */
(function () {
function load () {
var $anchorTagsJquery = $( '.mw-datatable > tbody > tr > td.TablePager_col_title > a:nth-child(1)' );
var pageList = [];
var $anchorTags = $anchorTagsJquery.toArray();
$anchorTags.forEach( function ( elem ) {
pageList.push( $( elem ).attr( 'title' ) );
}.bind( this )
);
var api = new mw.Api();
var chunkedArray = [];
for ( var i = 0; i < pageList.length; i += 50 ) {
chunkedArray.push( pageList.slice( i, i + 50 ) );
}
for ( var i = 0; i < chunkedArray.length; i++ ) {
var chunk = chunkedArray[i];
api.post( {
action: 'query',
prop: 'proofread',
titles: chunk.join( '|' ),
formatversion: 2,
format: 'json'
} ).done( function ( data ) {
var pages = data.query.pages;
for ( var i = 0; i < pages.length; i++ ) {
var page = pages[i];
if ( page.proofread ) {
var $selectedAnchorTags = $anchorTags.filter( function ( elem ) {
return $( elem ).attr( 'title' ) === page.title;
} );
for ( var j = 0; j < $selectedAnchorTags.length; j++ ) {
var $anchorTag = $selectedAnchorTags[j];
var $td = $anchorTag.parentElement;
var $tr = $td.parentElement;
if ( page.proofread.quality === 4 ) {
$td.style.backgroundColor = '#90ff90';
} else if ( page.proofread.quality === 3 ) {
$td.style.backgroundColor = '#ffe867';
} else if ( page.proofread.quality === 2 ) {
$td.style.backgroundColor = '#b0b0ff';
} else if ( page.proofread.quality === 1 ) {
$td.style.backgroundColor = '#ffa0a0';
/* $tr.style.display='none'; This should be a toggle? */
} else {
$td.style.backgroundColor = '#ddd';
}
}
}
}
}.bind( this ) );
}
}
mw.loader.using( 'mediawiki.api' ).then( function () {
if ( mw.config.get( 'wgPageName' ).startsWith( 'Special:LintErrors' ) ) {
window.addEventListener( 'load', function () {
load();
} );
if ( document.readyState === 'complete' || document.readyState === 'interactive' ) {
load();
}
}
} );
} )();