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.
// Add link icons with tooltips to h2 headers for current versions, old revisions, and diffs(function(){functionaddLinkIcons(){if(mw.config.get('wgIsMainPage')){return;}constheaders=document.querySelectorAll('h2[id]');headers.forEach(header=>{// Skip the table of contents headingif(header.id==='mw-toc-heading'){return;}constisCurrentVersion=!window.___location.search.match(/[?&]oldid=(\d+)/)&&!document.querySelector('.diff-currentversion-title');if(isCurrentVersion){// Add two icons for current versionaddIcon(header,'🔗',false,'Copy link to this section');// Chain link emoji for section linkaddIcon(header,'📌',true,'Copy permalink to this section');// Pushpin emoji for permalink}else{// Add single icon for old revision or diffaddIcon(header,'📌',true,'Copy link to this section of this specific revision');}});}functionaddIcon(header,iconText,isPermalink,tooltipText){consticon=document.createElement('span');icon.innerHTML=iconText;icon.style.cursor='pointer';icon.style.marginRight='5px';icon.style.fontSize='0.8em';icon.title=tooltipText;// Add tooltipicon.addEventListener('click',function(e){e.preventDefault();leturl;if(isPermalink){constcurrentId=mw.config.get('wgRevisionId');url=`${window.___location.origin}${window.___location.pathname}?oldid=${currentId}#${header.id}`;}else{url=`${window.___location.origin}${window.___location.pathname}#${header.id}`;}navigator.clipboard.writeText(url).then(()=>{mw.notify(`${isPermalink?'Permalink':'Section link'} copied to clipboard!`,{type:'success',tag:'urlCopy'});}).catch(()=>{mw.notify('Failed to copy URL',{type:'error',tag:'urlCopy'});});});header.insertBefore(icon,header.firstChild);}// Run the function when the DOM is fully loadedif(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',addLinkIcons);}else{addLinkIcons();}})();