Jump to content

User:JPxG/current-switcher.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JPxG (talk | contribs) at 09:53, 25 August 2021 (change to css display none for the hiding function, due to frankly bizarre bug where it would hide from 500 to 319, then restore to.... 371? what da). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// This is a very simple script. Basically, what it does is add buttons to "contributions" pages, like Special:Contributions/JPxG or Special:MyContributions, which allow you to toggle displaying current contributions.
// It's useful if you participate in a lot of discussions, and you want to see which of them have been responded to (i.e. which of your comments are no longer the current revision).
// - JPxG, 2021 08 24

$( function() {
    if( (window.location.href.indexOf( "Special:Contributions/" ) >= 0 ) || (window.location.href.indexOf( "Special%3AContributions" ) >= 0 )) {
    	$('.mw-pager-navigation-bar').append('&nbsp;&nbsp;Hide: <button type="button" id="currentrevs" class="crbutton" font-family:"monospace">current</button>');
		$('.mw-pager-navigation-bar').append('&nbsp;<button type="button" id="rollback" class="rbbutton">rollback</button>');
		$('.mw-pager-navigation-bar').append('&nbsp;<button type="button" id="huggle" class="hgbutton">huggle</button>');
		var currenthidden = 0;
		var rollbackhidden = 0;		
		var hugglehidden = 0;		
		// Set toggle variables.
		$('#currentrevs').click(function(e) {
			// Listener for "what to do if the 'current' button is clicked"
			if(currenthidden == 0){
				$( '.mw-contributions-current' ).css( 'display', 'none' );
				$( '.crbutton').css( 'font-weight', 'bold' );
			} // If toggle is 0, hide them.
			if(currenthidden == 1){
				$( '.mw-tag-mw-rollback' ).show();
				$( '.crbutton').css( 'font-weight', 'normal' );
			} // If toggle is 1, show them.
			currenthidden = (1 - currenthidden);
			// Either way, invert the toggle.
		});
		$('#rollback').click(function(e) {
			// Listener for "what to do if the 'rollback' button is clicked"
			if(rollbackhidden == 0){
				$( '.mw-tag-mw-rollback' ).hide();
				$( '.rbbutton').css( 'font-weight', 'bold' );
			} // If toggle is 0, hide them.
			if(rollbackhidden == 1){
				$( '.mw-tag-mw-rollback' ).show();
				$( '.rbbutton').css( 'font-weight', 'normal' );
			} // If toggle is 1, show them.
			rollbackhidden = (1 - rollbackhidden);
			// Either way, invert the toggle.
		});
		$('#huggle').click(function(e) {
			// Listener for "what to do if the 'huggle' button is clicked"
			if(hugglehidden == 0){
				$( '.mw-tag-huggle' ).hide();
				$( '.hgbutton').css( 'font-weight', 'bold' );
			} // If toggle is 0, hide them.
			if(hugglehidden == 1){
				$( '.mw-tag-huggle' ).show();
				$( '.hgbutton').css( 'font-weight', 'normal' );
			} // If toggle is 1, show them.
			hugglehidden = (1 - hugglehidden);
			// Either way, invert the toggle.
		});		
    }
} );