User:Skizzerz/logcount

Log counting (untested). Copy/paste the following into your user js:

/** * Counter for Special:Log * By Skizzerz (http://www.wikia.com/wiki/User:Skizzerz) var ugPage = wgServer + wgScript + '?title=' + escape(wgPageName);

function logCount { if(wgPageName == 'Special:Log' && queryString('user') != null && queryString('user') != '') { addPortletLink('p-cactions', 'javascript:doLogCount;', 'count', 'logcount', 'Count', false, false); } if(queryString('docount') == 1) doLogCount; }

function doLogCount { if(queryString('limit') != '5000') { window.location = ugPage + '&user=' + queryString('user') + '&type=' + queryString('type') + '&limit=5000&docount=1'; return; } var lis = document.getElementsByTagName('li'); var count = 0; for(var i = 0; i < lis.length; i++) { if(lis[i].innerHTML.match(/[0-9][0-9]:[0-9][0-9]/)) count++; } makeLogCount(count); }

function makeLogCount(count) { var cb = document.createElement('div'); var fs = document.createElement('fieldset'); var lg = document.createElement('legend'); var sp = document.createElement('span'); cb.id = 'logCount-box'; cb.style.display = 'block'; lg.innerHTML = 'Log count'; fs.appendChild(lg); sp.innerHTML = 'Number of entries in this log: ' + count + ''; cb.style.color = 'black'; fs.appendChild(sp); cb.appendChild(fs); var cs = document.getElementById('contentSub'); cs.appendChild(cb); var ca = document.getElementById('ca-count'); ca.getElementsByTagName('a')[0].href = 'javascript:hideLogCount;'; ca.className = 'selected'; }

function showLogCount { document.getElementById('ca-count').className = 'selected'; document.getElementById('ca-count').getElementsByTagName('a')[0].href = 'javascript:hideLogCount;'; document.getElementById('logCount-box').style.display = 'block'; }

function hideLogCount { document.getElementById('ca-count').className = ''; document.getElementById('ca-count').getElementsByTagName('a')[0].href = 'javascript:showLogCount;'; document.getElementById('logCount-box').style.display = 'none'; } addOnloadHook(logCount);

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }	}	return null; }