MediaWiki:Gadget-shortnewpages.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
function highlightShortNewpages() {
	if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Newpages' ) {
		var targetContent = document.getElementById( 'bodyContent' );
		var links = targetContent.getElementsByTagName( 'li' );
		for ( var l = 0; l < links.length; l++ ) {
			var liContent = links[l].textContent;
			var sizeText = liContent.substring( liContent.indexOf( '[' ) + 1, liContent.indexOf( 'bytes]' ) );
			var sizeBytes = sizeText.replace( ',', '' );
			if ( sizeBytes > 10000 ) {
				links[l].style.backgroundColor = 'yellow';
			}
			if ( sizeBytes < 1500 ) {
				links[l].style.backgroundColor = '#fdd';
			}
			if ( sizeBytes < 1000 ) {
				links[l].style.backgroundColor = '#fbb';
			}
			if ( sizeBytes < 100 ) {
				links[l].style.backgroundColor = '#f44';
			}
		}
	}
}
$( highlightShortNewpages );