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>/** * Admin highlighter 3.0 * --------------------- * Derivative of of User:Theopolisme/Scripts/adminhighlighter.js * Changes: cache list of admins, and tweak css to use nicer one by Jorm. * This script highlights links to admins' userpages or talkpages in bodyContent * (that is, everything but the tabs, personal links at the top of the screen and sidebar) * by giving them a light background and border. * * @authors Galobtter, Theopolisme, Amalthea, Ais523 */varprevPostRequest,data;varhighlight=function(data){ADMINHIGHLIGHT_EXTLINKS=window.ADMINHIGHLIGHT_EXTLINKS||false;ADMINHIGHLIGHT_NAMESPACES=[-1,2,3];mw.loader.using(['mediawiki.util','mediawiki.Uri','mediawiki.Title']).then(function(){mw.util.addCSS("a.userhighlighter_sysop { background-color: rgba(100, 149, 237, 0.25) !important; border-top: .05em dashed rgba(100, 149, 237, 0.5); border-bottom: .05em dashed rgba(100, 149, 237, 0.5); }"+"a.userhighlighter_sysop.mw-changeslist-title { background-color: transparent !important; border-color: transparent !important; }");$('#bodyContent a').each(function(index,linkraw){try{varlink=$(linkraw);varurl=link.attr('href');if(!url||url.charAt(0)==='#')return;// Skip <a> elements that aren't actually links; skip anchorsif(url.lastIndexOf("http://",0)!==0&&url.lastIndexOf("https://",0)!==0&&url.lastIndexOf("/",0)!==0)return;//require http(s) links, avoid "javascript:..." etc. which mw.Uri does not supportvaruri=newmw.Uri(url);if(!ADMINHIGHLIGHT_EXTLINKS&&!$.isEmptyObject(uri.query))return;// Skip links with query strings if highlighting external links is disabledif(uri.host=='en.wikipedia.org'){varmwtitle=newmw.Title(mw.util.getParamValue('title',url)||decodeURIComponent(uri.path.slice(6)));// Try to get the title parameter of URL; if not available, remove '/wiki/' and use thatif($.inArray(mwtitle.getNamespaceId(),ADMINHIGHLIGHT_NAMESPACES)>=0){varuser=mwtitle.getMain().replace(/_/g," ");if(mwtitle.getNamespaceId()===-1)user=user.replace('Contributions/','');// For special page "Contributions/<username>"if(data[user]==1){link.addClass('userhighlighter_sysop');// Override the above color by using `a.userhighlighter_sysop.userhighlighter_sysop {background-color: COLOR !important}`}}}}catch(e){// Sometimes we will run into unparsable links, so just log these and move onconsole.error('Admin highlighter recoverable error',e.message);}});});};varmain=function(){// if called a second time, should have dataif(data){highlight(data);}// Cache the admin json for a period of timetry{data=JSON.parse(localStorage.getItem('adminjson'));}catch(e){console.error('Admin highlighter: failed to parse cached admin json object',e.message);}if(!data||!data.date||(Date.now()-data.date)>3600000){// 1 hour in milliseconds$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:AmoryBot/crathighlighter.js/sysop.json').then(function(result){data=result;data.date=Date.now();localStorage.setItem('adminjson',JSON.stringify(data));highlight(data);});}else{highlight(data);}};main();if(mw.config.get('wgCanonicalSpecialPageName')==='Watchlist'){/* Rerun every time update watchlist */$(document).ajaxSend(function(event,request,settings){/** * Should not update on regular pings by the watchlist checking for an update * Wait for the next ping after a post request * (which is involved in updating watchlist) */if(settings.type==='POST'){prevPostRequest=true;return;}if(prevPostRequest&&settings.url.indexOf('Special:Watchlist')===-1&&settings.type==='GET'){main();prevPostRequest=false;}});}//</nowiki>