User:Technical 13/common.js

/* TEST SCRIPTS ARE AT TOP OF THE PAGE */// Line 1 $('table a:contains("hist")').each(function {	var link = $(this).attr('title');	var linkNS = link.substr(0, link.indexOf(":")+1);	var linkPageName = link.substr(link.indexOf(":")+1, link.length); /* Add link to companion page */// Line 6	var linkTS = linkNS;	if(linkNS.length === 0){		linkTS = "Talk:";	} else if(linkNS.indexOf(" talk") === -1){		linkTS = linkNS.replace(":", " talk:");	} else if(linkNS == "Talk:"){		linkNS = "";	} else {		linkNS = linkNS.replace(" talk:", ":");	} /* These pages should be a redlink if they doesn't exist, but checking to see if they exists is for another day... */// Line 17	if(link.search(/[Tt]alk/) === -1){		$(this).after(' | Talk');	} else {		if (linkNS.length === 0) {			$(this).after(' | Main');		} else {			$(this).after(' | ' + linkNS.replace(":", "") + ''); }	} /* Add link to all page logs */// Line 27 $(this).next("a#comp").after(' | logs'); /* Get user info */// Line 29 var EditorUsername = $(".mw-userlink").attr("title"); EditorUsername = EditorUsername.substr(EditorUsername.indexOf("User:"), EditorUsername.length); var EditorInfo = []; $.ajax({		url: '//ddowiki.com/api.php?action=query&list=allusers&auprop=blockinfo|editcount|groups&aulimit=1&aufrom=' + EditorUsername,		dataType: 'json',		success: function (result) {		if (result.query.allusers.u.blockedby) {			var isBlocked = [];			isBlocked[blocker] = result.query.allusers.u.blockedby;			isBlocked[reason] = result.query.allusers.u.blockedreason;			isBlocked[expires] = result.query.allusers.u.blockexpiry;			EditorInfo[EditorUsername][block] = isBlocked;			console.warn("%o", isBlocked);		}		EditorInfo[EditorUsername][editcount] = result.query.allusers.u.editcount;		EditorInfo[EditorUsername][groups] = result.query.allusers.u.groups;	} }); console.info("%o", EditorInfo); }); /* Add an edit count to each users contributions link /// Line 43/* var EditorUsername = "UNKNOWN"; var EditCount = new Array; $('span.mw-usertoollinks').each(function { EditorUsername = $(this).find("a[title*='Special:Contributions/']").attr("title"); // TRON //EditorUsername = EditorUsername.substr(EditorUsername.indexOf("Special:Contributions/") + 1, EditorUsername.length); // TODO: Hit the API for the user and get the total edit count if the username/edit count is not already in an array // Query: '/api.php?action=query&list=allusers&auprop=editcount&aulimit=1&aufrom=' + EditorUsername EditCount[EditorUsername] = -1; //For now // TODO: Hit the API for the user and get the total edit count $(this).find("a[title*='Special:Contributions/']").before(' ' + EditCount[EditorUsername] + ' '); });*/ console.info("%o", EditorInfo); /* Change block link if already blocked */ // API Query: '/api.php?action=query&list=allusers&auprop=blockinfo&aulimit=1&aufrom=' + EditorUsername

/*	var EditorUsername = $(".mw-userlink").attr("title"); EditorUsername = EditorUsername.substr(EditorUsername.indexOf("User:"), EditorUsername.length); var EditorInfo = new Array; $.ajax({		url: '//ddowiki.com/api.php?action=query&list=allusers&auprop=blockinfo|editcount|groups&aulimit=1&aufrom=' + EditorUsername,		dataType: 'jsonp',		success: function (result) {			EditorInfo[EditorUsername][block] = isBlocked["blocker" => result.query.allusers.u['blockedby'],"reason" => result.query.allusers.u['blockedreason'],"expires" => result.query.allusers.u['blockexpiry']];			EditorInfo[EditorUsername][editcount] = result.query.allusers.u['editcount'];			EditorInfo[EditorUsername][groups] = result.query.allusers.u.groups;		}	});

/* Make [rollback] and "blocklink" disappear */ //Personally, I only want this working on my contributions page.// Line 74 if (/* wgPageName == "Special:Watchlist" || wgPageName == "Special:RecentChanges" || */wgCanonicalSpecialPageName == "Contributions") { $('span.mw-rollback-link').remove; $('span.mw-usertoollinks').each(function {		$(this).children('a:last').replaceWith("-");		$(this).html($(this).html.replace(" | -", ""));	}); }

/* Edit Counter */// Line 83 /* User:Technical 13/Scripts/Edit counter */ var editPage = 'Edit count'; var tableStyle = 'width: 268px;'; mw.loader.load( '//ddowiki.com/index.php?title=User:Technical_13/Scripts/Edit_counter.js&action=raw&ctype=text/javascript' );

// importScript( "MediaWiki:Gadget-SysopTools.js" );//Commented out when gadgets extension is working... importScript( "MediaWiki:Gadget-listStyles.js" );

/* Temporary name change mechanic until Extension:User Merge and Delete properly updates the edit count */ $('h1[id^="title"]').each(function {	this.innerHTML = this.innerHTML.replace("User:Technical 13", "User:ShoeMaker"); }); $('a[href^="/page/User:Technical_13"]').each(function {	this.innerHTML = this.innerHTML.replace("Technical 13", "ShoeMaker"); });

/* Shrink all things on my "Contributions" page that no-one has edited since me. */ $('.mw-uctop').closest('li').css({"font-size":"6px", "text-decoration":"italic"});

/* Refresh my WatchList page when viewing every minute */ if (wgPageName == "Special:Watchlist" || wgPageName == "Special:RecentChanges") { setTimeout(function{location = ''},60000); /*	importScripts( 'User:Joenuts/Watchlist.js' ); var timeNow = new Date; var minNow = timeNow.getMinutes; var minNow = minNow - 3; var timeCheck = new Date; timeCheck.setMinutes(minNow); var postTime = $('td.mw-enhanced-rc').html; var nbsp = (postTime.match(/ /g)||[]).length; for (i=0;iN ', ''); var postTime = postTime.replace('m ', ''); var postTime = postTime.replace('b ', ''); var postTime = postTime.replace('! ', ''); var postTime = postTime.split(':', '2'); var postHour = postTime[0]; var postMin = postTime[1]; var timePost = new Date; timePost.setHours(postHour); timePost.setMinutes(postMin); var timePost = timePost.getTime; var timeCheck = timeCheck.getTime; var timeNow = timeNow.toLocaleTimeString; var headTitlePrefix = "";// Initialize variable var headTitle = timeNow + " - " + document.title; if (timePost >= timeCheck) { var enhRC = $('td.mw-enhanced-rc').html; $('td[class^="mw-enhanced-rc"]').each(function {this.innerHTML = this.innerHTML.replace(enhRC, ' ' + enhRC + ' ');}); /* Using this styles ALL times	  $('td[class^="mw-enhanced-rc"]').css({"font-weight":"bold", "font-size":"12pt"});*/ var headTitlePrefix = "N"; }	if ($('td.mw-enhanced-rc abbr.unpatrolled').length != 0){ var patrolRequired = $('td.mw-enhanced-rc abbr.unpatrolled').text; var patrolsRequired = patrolRequired.length; if (patrolsRequired > 1) { patrolRequired = patrolsRequired + "!"; } var headTitlePrefix = patrolRequired + headTitlePrefix; }	if (headTitlePrefix){ headTitle = headTitlePrefix + " - " + headTitle; } document.title = headTitle; }