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.
/* If you want to use this script, simply add the following line to your [[Special:Mypage/monobook.js]]:importScript('User:Dispenser/alttextexplorer.js'); // Linkback: [[User:Dispenser/alttextexplorer.js]]* (Please keep the comment so I can see how many people use this). */(function(){return;// early exit - script is broken.if(typeof(noaltcss)=='undefined'){appendCSS(".alt-block{background:#444; color:#fff; line-height:1.3em; font-size:0.8em; padding:2px; text-align:left;} .alt-block span{background:#444;}")appendCSS(".alt-inline{border:1px solid #444; display:inline-block; position:relative;} .alt-inline div{background:#444; color:#fff; font-size:80%; position:absolute; top:0; display:none;; width:20em; z-index:15;} .alt-inline:hover div{display:block;}")appendCSS("img.alt-nolink { border:2px solid sandybrown;}")appendCSS("img.alt-none { border:2px solid red;}")appendCSS("img.alt-nolink.alt-none, img.tex.alt-nolink { border:none;}")}varBlockNodes=/^(?:BR|BLOCKQUOTE|BUTTON|CENTER|DIV|H[1-6]|OL|UL|DL|TABLE|TR|TD|TH|P|PRE)$/functionaddAlts(){varimage;varbodyc=document.getElementById('bodyContent')||document.getElementById('content')||document.getElementById('mw_content')varimages=bodyc.getElementsByTagName('img')for(vari=0;(image=images[i]);i++){// Skip skins or extensions iconsif(image.src.indexOf('/skins-1.5/')!=-1||image.src.indexOf('/extensions/')!=-1)continuevaruseblockvarnt=imagevarcontainer=ntwhile(true){if(nt.nextSibling){nt=nt.nextSiblingif(nt.nodeType==3){if(/\S/.test(nt.nodeValue)){useblock=false;break;}}elseif(nt.nodeType==1){useblock=BlockNodes.test(nt.tagName)break;}}else{// Assume that we are at the end of the elementsif(BlockNodes.test(container.parentNode.tagName)){useblock=true;break;}else{container=nt=container.parentNode;}}}/* Deal with geobox redpog elements */if(useblock&&container.parentNode.tagName=="DIV"&&container.parentNode.style.position=="relative"){if(container.parentNode.parentNode.tagName=="DIV")container=container.parentNodeelseuseblock=false}/* Make changes */if(image.alt==''){image.className+=" alt-none";}elseif(useblock){varn=container.parentNode.insertBefore(document.createElement('div'),container.nextSibling);n.appendChild(document.createElement('span')).appendChild(document.createTextNode(image.alt));n.className="alt-block";n.style.width=(image.width-2)+'px';}else{varn=container.parentNode.insertBefore(document.createElement('span'),container);n.appendChild(container);n.className="alt-inline"n.appendChild(document.createElement('div')).appendChild(document.createTextNode(image.alt));}if(image.parentNode.tagName!='A'){image.className+=" alt-nolink";}elseif(image.alt){varalt=escape(image.alt.replace(/ /g,'_'))vara=image.src.match(newRegExp(RegExp.escape(alt)+"(|\\.\\w{3})$"))if(a)image.className+=" alt-none"}}}if(doneOnloadHook)addAlts();//if imported dynamicallyelseaddOnloadHook(addAlts);}());