User:Ll0l00l/gadget-gif-hider.js
Appearance
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. |
Documentation for this user script can be added at User:Ll0l00l/gadget-gif-hider. |
// hide gifs after mouse-out from image box. return mouse to image for unhide it.
// -- User:ll0l00l 2010-06-05T22:32:36
// ver 1.1
if ( wgNamespaceNumber >= 0 )
addOnloadHook(function() {
var gifhiderid=new Number(0);
if ( wgNamespaceNumber != 0 ) return;
var ids = ['wikiPreview','bodyContent','mw_contentholder','article'];
for (var j = 0;j<ids.length;j++)
{
var el = document.getElementById( ids[j] );
if (el)
{
var el2 = el.getElementsByTagName( 'a' );
for (var i=0;i<el2.length;i++)
{
if (el2[i].className.match("image"))
{
if (el2[i].href.match('.gif'))
{
gifhiderid++;
var innerHTMLtmp = el2[i].innerHTML;
var ss = document.createElement('script');
ss.type = 'text/javascript';
var scr = 'function mouseOver_gifhider'+gifhiderid.toString()+'(){document.getElementById("gifhiderid'+gifhiderid.toString()+'").src ="'+el2[i].getElementsByTagName('img')[0].src+'";}function mouseOut_gifhider'+gifhiderid.toString()+'(){document.getElementById("gifhiderid'+gifhiderid.toString()+'").src ="http://upload.wikimedia.org/wikipedia/commons/d/d2/Blank.png";};';
ss.text = scr;
var hh = document.getElementsByTagName('head')[0];
hh.appendChild(ss);
innerHTMLtmp = innerHTMLtmp.replace('<img ','<script type="text/javascript"></script> <img id="gifhiderid'+gifhiderid.toString()+'" onmouseover="mouseOver_gifhider'+gifhiderid.toString()+'();return false"onmouseout="mouseOut_gifhider'+gifhiderid.toString()+'();return true" ');
el2[i].innerHTML = innerHTMLtmp;
}
}
}
}
}
return;
});