User:Jack Phoenix/monobook.js

// ***************************************************************** // Load various external scripts // ***************************************************************** //importScriptURI( 'http://community.wikia.com/index.php?title=User:Splarka/fastdelete.js&action=raw&ctype=text/javascript&dontcountme=s' ); //importScriptURI( 'http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js&action=raw&ctype=text/javascript&dontcountme=s' );

// ***************************************************************** // Custom automatic delete buttons // ***************************************************************** // Adds customizable one-click deletion buttons to any deletable page. // Requires User:Splarka/fastdelete.js /* var fdButtons = []; fdButtons[fdButtons.length] = { 'summary': 'nobody cares', 'label': 'UN:N' }; // ***************************************************************** // &bot=1 on contribs pages. // @author Splarka // ***************************************************************** function hideRollback { var botlink = document.location.href; if ( botlink.indexOf( '?' ) == -1 ) { botlink += '?bot=1'; } else { botlink += '&bot=1'; }	mw.util.addPortletLink( 'p-cactions', botlink, '&bot=1', 'ca-bot' ); } if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Contributions' ) { $( hideRollback ); }

// ***************************************************************** // Thing to add a "Hide(/Show) translations" link to Special:WhatLinksHere/ // for filtering out translated pages from the list // Date: 4 May 2022 // ***************************************************************** $( function hideTranslationsOnWhatLinksHere {	if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Whatlinkshere' ) {		return;	}

var translationsShown = true;

function reallyDoTranslationVisibilityStateChange( e ) { // Don't follow the #, obviously e.preventDefault;

// Loop over the list of page titles $( 'ul#mw-whatlinkshere-list li a' ).each( function ( i ) {			// If a page title contains the / character followed by what			// looks to be an ISO-639 language code (e.g. fi, sr-el, vec, zh-hans),			// hide it!			// Kudos to Vulpix (User:Ciencia Al Poder) for this regex!			//  The explanation should be: 2 or 3 alpha characters, optionally followed by a hyphen and 2 alpha characters, at the end of the string			if ( $( this ).attr( 'title' ) !== undefined && $( this ).attr( 'title' ).match( /\/[a-z]{2,3}(-[a-z]{2})?$/ ) ) {				$( this ).parent.toggle;			}		} );

// Update totals var countText = $( '#mw-content-text p' )[1].innerHTML.trim; // If it contains a number (which it should), ... if ( countText.match( /[0-9]+/ ) ) { var oldCount = countText.match( /[0-9]+/ )[0]; // Note the different, more precise selector used here than above; // here we _must_ ignore the links inside span.mw-whatlinkshere-tools // and we also must ignore the links we just hid above, d'oh... var newCount = $( 'ul#mw-whatlinkshere-list li > a:visible' ).length;

// For determining what word, "show" or "hide", we show in the filter area translationsShown = ( newCount > oldCount );

// Actually touch the text inside the element instead of just...storing our // fancy new stuff in a variable and discarding it. That'd be mighty stupid now, // wouldn't it? $( '#mw-content-text p' )[1].innerHTML = countText.replace( oldCount, newCount ); }

// Update the link text $( '#translation-visibility-filter-link' ).text(			( translationsShown ? 'Hide' : 'Show' )		); }

// Expose this so that we can use it inline below // FIXME awful window.reallyDoTranslationVisibilityStateChange = reallyDoTranslationVisibilityStateChange;

// Inject our filter link (and the pipe separator & spacing) to the main filter area $( 'div#mw-content-text fieldset' )[1].innerHTML += ' | Hide translations'; } );