User:Ale jrb/Scripts/contreverse.js

From Wikipedia, the free encyclopedia
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.
	
	function contReverseMain() {
		var me = this;
		
		this.init = function () {
			var action  = mw.config.get('wgAction');
			var pagename = mw.config.get('wgPageName');
			if ( ( action == 'view' ) && ( pagename == 'Special:Contributions' ) ) {
				var bodyContent = document.getElementById ( 'bodyContent' );
				regTest = /\(((?:<a href=[^<>]+?>)?diff(?:<\/a>)?)(?: |&nbsp;)\| (<a href=[^<>]+?>hist<\/a>)\)/ig;
				bodyContent.innerHTML = bodyContent.innerHTML.replace ( regTest, "($2 | $1)" );
			}
		}
	}

	var contReverse = new contReverseMain ();
	$(window).on( 'load', contReverse.init );