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.
// OfferToHideImages.js// // This script adds a short message offering to hide all the images the page. // The message, once clicked, temporarily hides all images.// All images can be restored by clicking on a message at the top of the page. // All images can be restored by clicking on any of the "unhide all" messages above each image. // Experimental. //Global Mode//AlwaysOffer = true; // Always offer to hide regardless of page//List modeAlwaysOffer=false;// Only offer to hide images on specific pages// In List Mode, The "Hide All Images" option will be offer only on these pages: varOfferImageHidePages=["Muhammad","Flag desecration","Bahá'u'lláh","Piss Christ"];// Tweakable messages: Top of article offer to hide image, Top offer to unhide images, and Per-Image offers to unhide images. varHideOfferHTML="To hide all images in this article, <a onCLick='HideAllImages()'>click here</a>.";//Would you like to hide all images on page?varUnhideOfferHTML="<a onCLick='UnHideAllImages() '>Click here</a> to reveal all images.";// Would you like to see all images again?varUnhideImgHTML="<a class=\"UnhideImageLink\" onCLick='UnHideAllImages(); return false;' href=\"\">Unhide All</a>";// Would you like to see images after all? (or in future "Would you like to see just this image and only this image?")if(AlwaysOffer==true){OfferHideAllImages();}// Global Modeelse// List mode{// Is this page on this list? varLocalPageTitle=mw.config.get('wgTitle');// Get the Page Titleif(OfferImageHidePages.indexOf(LocalPageTitle)!=-1)// Is this page on the list?{// Yes, this page is on the list. //alert("Page title = "+mw.config.get('wgTitle')); // For debuggingOfferHideAllImages();}}//*************************************// OfferHideAllImages() is a function that add a message to an appropriate part of the page. functionOfferHideAllImages(){document.getElementById('contentSub').innerHTML+=HideOfferHTML;}// HideAllImages is a function that gets each Img, hides them, and puts up Unhide offersfunctionHideAllImages(){varimgs=document.getElementsByTagName("img");for(vari=0;i<imgs.length;i++)HideImage(imgs[i]);OfferUnHideAllImages()}// HideImage is the function that actually hides an IMG and replaces it with Unhide Offer.functionHideImage(myNode){myNode.style.visibility="hidden";// Hide it// Create an Unhide Offer at this specific imagevarnewNode=document.createElement('div');// Make New DivnewNode.innerHTML=UnhideImgHTML;// Add html to Div myNode.parentNode.insertBefore(newNode,myNode);// Insert the Div}// OfferUnHideAllImages() is a function that updates the page to allow unhiding. functionOfferUnHideAllImages(){document.getElementById('contentSub').innerHTML=UnhideOfferHTML;}// UnHideAllImages is a function that will unhide all images.functionUnHideAllImages(){// Restore the imagesvarimgs=document.getElementsByTagName("img");for(vari=0;i<imgs.length;i++)imgs[i].style.visibility="visible";// Erase offers to unhidedocument.getElementById('contentSub').innerHTML="";// Erase top of article offer$('.UnhideImageLink').hide();// Erase per image offer// Recreate hide offer at top. OfferHideAllImages();}//*************************************