Jump to content

User:DannyS712/ExpandHistory.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.
// Install the newest version with:
// <code><nowiki>		{{subst:Iusc|User:DannyS712/ExpandHistory.js}}																	</nowiki></code>
// or with
// <code><nowiki>		importScript( 'User:DannyS712/ExpandHistory.js' ); // Backlink: [[User:DannyS712/ExpandHistory.js]] 			</nowiki></code> 
//
// If forking this script, please note my contributions / give me credit
$(function (){
var ExpandHistory_config = {
	name: '[[User:DannyS712/ExpandHistory|ExpandHistory.js]]',
	version: 1.0,
	debug: false
};
mw.loader.using( 'mediawiki.util', function () {
    $(document).ready( function () { 
    	var action = mw.config.get('wgAction');
    	if (action && action === 'history'){
    		ExpandHistory();
    	}
    } );
} );
function ExpandHistory(){
	var links = $('a:textEquals("500")');
	var thousand;
	if (ExpandHistory_config.debug) console.log( links );
	links.each( function() {
		thousand = $(this).clone();
		thousand[0].href = thousand[0].href.replace(/limit=500/, 'limit=1000');
		thousand[0].textContent = '1000';
		thousand = thousand[0];
		this.after( thousand );
		this.after( ' | ' );
	});
}
// Attribution: copied from https://stackoverflow.com/questions/6673777/select-link-by-text-exact-match#
$.expr[':'].textEquals = function(a, i, m) {
    return $(a).text().match("^" + m[3] + "$");
};
});