Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
//<nowiki>/* * Small script to help navigate the CU log. * Turns timestamps of a filtered CU log like on [//en.wikipedia.org/wiki/Special:CheckUserLog?cuSearchType=target&cuSearch=Example] * into links that try to locate the entry in the full log. * This simplifies looking at the context of a previous check. */jQuery(function($){if(mw.config.get('wgPageName')=='Special:CheckUserLog'){mw.loader.using(['mediawiki.util','mediawiki.user','moment'],function(){varparaCuloghighlight=mw.util.getParamValue('culogHighlight');varparaCusearch=mw.util.getParamValue('cuSearch');if(!paraCuloghighlight&&!paraCusearch)return;//collect all date text nodesvardateNodes=$("#bodyContent > #mw-content-text > ul > li").map(function(i,n){return$(n).contents().first();})//highlight all nodes with a matching dateif(paraCuloghighlight){dateNodes.each(function(i,n){if(n[0].textContent!==paraCuloghighlight)return;//highlightn.wrap("<span style='background-color:#FCC;'/>");//and scroll into viewvarwindowtop=$(window).scrollTop();varwindowbottom=windowtop+$(window).height();varntop=n.parent().offset().top;varnbottom=ntop+n.parent().outerHeight(true);if(ntop<windowtop)$(window).scrollTop(ntop);elseif(nbottom>windowbottom)$(window).scrollTop(nbottom+windowtop-windowbottom);});}//link all date nodes to the full log viewif(paraCusearch){varlocale=mw.config.get("wgUserLanguage");// Date parsing in Javascript is aweful.// Localized, configurable date output on Mediawiki doesn't make this any easier.// It's conceivable to write a parser that could match /most/ variants out there ...// but I'll just strict parse the English date formats insteadvarparsingStrings={"en":{"mdy":"HH:mm, MMMM D, YYYY","dmy":"HH:mm, D MMMM YYYY","ymd":"HH:mm, YYYY MMMM D","ISO 8601":"YYYY-MM-DDTHH:mm:ss",},}varlocaleParsingStrings=parsingStrings[locale];if(localeParsingStrings)varparsingString=localeParsingStrings[mw.config.get("wgDefaultDateFormat")];if(parsingString)varparseDate=function(input){returnmoment(input,parsingString+", ",true);}elsevarparseDate=moment;//Note: We append ", " above since the messages building the log lines, e.g. MediaWiki:Checkuser-log-entry-userips,// look like this: $3, $1 got IP addresses for $2// That is, they do in English! Might need adapting for other languages, or imprecise parsing, or some markup in the messages!//function lifted from popups.jsfunctiongetTimeOffsetMinutes(tz){if(tz&&typeoftz==='string'){if(tz.indexOf('|')>-1)// New formatreturnparseInt(tz.split('|')[1],10);elseif(tz.indexOf(':')>-1)// Old formatreturn(parseInt(tz,10)*60+parseInt(tz.split(':')[1],10));}return0;}vartimeOffsetMinutes=getTimeOffsetMinutes(mw.user.options.get("timecorrection"));//calculate one hour into the future; this will be the upper limit of the log displayedtimeOffsetMinutes-=60;dateNodes.wrap(function(){vardateText=$(this)[0].textContent;vartimestamp=parseDate(dateText);if(!timestamp.isValid())return;timestamp.subtract(timeOffsetMinutes,'minutes');vardateOffsetString=timestamp.format("YYYYMMDDHHmm");return"<a href='"+mw.config.get("wgScript")+"?title=Special:CheckUserLog&offset="+mw.util.rawurlencode(dateOffsetString)+"&culogHighlight="+mw.util.rawurlencode(dateText)+"' />";});}});}});//</nowiki>