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:32, 25 August 2021 (make it a toggle switch instead because why not). 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;Toggle: <button type="button" id="currentrevs-hide">current</button><button type="button" id="currentrevs-show">show</button>');
		$('.mw-pager-navigation-bar').append('&nbsp;Rollback: <button type="button" id="rollback-hide">hide</button><button type="button" id="rollback-show">show</button>');
		$('.mw-pager-navigation-bar').append('&nbsp;Huggle: <button type="button" id="huggle-hide">hide</button><button type="button" id="huggle-show">show</button>');
		var currenthidden = 0;
		// Set toggle variable.
		$('#currentrevs-hide').click(function(e) {
			currenthidden = (1 - currenthidden);
			if(currenthidden == 0){
				$( '.mw-contributions-current' ).hide();
			}
			if(currenthidden == 1){
				$( '.mw-contributions-current' ).show();
			}
		});
		$('#currentrevs-show').click(function(e) {
			$( '.mw-contributions-current' ).show();
		});
		$('#rollback-hide').click(function(e) {
			$( '.mw-tag-mw-rollback' ).hide();
		});
		$('#rollback-show').click(function(e) {
			$( '.mw-tag-mw-rollback' ).show();
		});
    }
} );