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.
/* timeless-newMessageHighlight A script to highlight the username in yellow when there are new messages on your user talk page (since the in Timeless skin, the talk page link is hidden in a dropdown). This script should only be used with the Timeless skin -- add it to your timeless.js, not your common.js! For details on why this is not done by the skin, nor by the Echo extension, see these tasks: https://phabricator.wikimedia.org/T215695 and https://phabricator.wikimedia.org/T216046*/// Wait for page load$(function($){varMOBILE_BREAKPOINT=850;// pxvarhasTalkpageAlert;// BooleanvarrecheckInterval;varrecheckTimeout;varclearRecheckingIntervalAndTimeout=function(){if(recheckInterval)window.clearInterval(recheckInterval);if(recheckTimeout)window.clearTimeout(recheckTimeout);// Reset click handler. Seems to be needed, possibly from Echo mucking about// with the <a> elements?if(onNotificationAlertClick){$('#pt-notifications-alert a').off("click.highlightingCheck");$('#pt-notifications-alert a').on("click.highlightingCheck",onNotificationAlertClick);}};// Desktop (and tablet) viewsvarsetDesktopStyles=function(){$('#personal').css({'background-color':'#fc3','background-blend-mode':'multiply','background-clip':'content-box'});};varremoveDesktopStyles=function(){$('#personal').css({'background-color':'initial','background-blend-mode':'initial','background-clip':'initial'});};varhasDesktopStylesSet=function(){return$('#personal').css('background-color')==="rgb(255, 204, 51)";// #fc3;};// Mobile views (only needs styles when below breakpoint)varaddStylesForMobileView=function(){$('#personal h2').css({'background-color':'#fc3','background-blend-mode':'multiply'});};varremoveStylesForMobileView=function(){$('#personal h2').css({'background-color':'initial','background-blend-mode':'initial'});};varhasMobileViewStylesSet=function(){return$('#personal h2').css('background-color')==="rgb(255, 204, 51)";// #fc3;};varsetMobileViewStyles=function(){varisStyled=hasMobileViewStylesSet();if(window.innerWidth<=MOBILE_BREAKPOINT&&!isStyled){setTimeout(addStylesForMobileView,1);}elseif(window.innerWidth>MOBILE_BREAKPOINT&&isStyled){setTimeout(removeStylesForMobileView,1);}};// Set state of desktop / mobile view stylesvarsetUpHighlighting=function(){hasTalkpageAlert=$('#user-tools').has('.mw-echo-alert').length>0;if(hasTalkpageAlert){if(!hasDesktopStylesSet()){setDesktopStyles();clearRecheckingIntervalAndTimeout();}setMobileViewStyles();}else{if(hasDesktopStylesSet()){removeDesktopStyles();clearRecheckingIntervalAndTimeout();}if(hasMobileViewStylesSet()){removeStylesForMobileView();}}};// Set initial statesetUpHighlighting();/* Respond when the window resizes, throttled to every 0.2 seconds. * Derived from code by Mozilla Contributors, licensed under CC-BY-SA 2.5, * at https://developer.mozilla.org/en-US/docs/Web/Events/resize#setTimeout */window.addEventListener("resize",resizeThrottler,false);varresizeTimeout;varactualResizeHandler=function(){returnhasTalkpageAlert&&setTimeout(setMobileViewStyles,1);};functionresizeThrottler(){// ignore resize events as long as an actualResizeHandler execution is in the queueif(!resizeTimeout){resizeTimeout=setTimeout(function(){resizeTimeout=null;actualResizeHandler();},200);}}/* Clicks on the notifications menu may add/remove the yellow background from the talkpage link, so we do a check every 5 seconds to see if we need to reset the highlighting (on or off). For efficiency this is time-limited to period starting from when the notifications-alert icon is clicked, and ending either when the highlighting state changes, or 60 seconds have elapsed. Adding a callback to a hook would be prefereable, but Echo doesn't seem to provide such hooks. And the mark as read/unread links aren't available till some time after the user clicks on the bell icon, so click-event callbacks can't be used either. :( */varonNotificationAlertClick=function(){recheckInterval=window.setInterval(setUpHighlighting,5000);recheckTimeout=window.setTimeout(function(){clearRecheckingIntervalAndTimeout();},60000);};$('#pt-notifications-alert a').on("click.highlightingCheck",onNotificationAlertClick);});