User:HectorMoffet/ShowOnlyToLoggedInUsers.js

// // To install this script, // // 1) Edit your common.js file by going to Special:MyPage/common.js // 2)  Add the following line to that file: //        importScript('User:HectorMoffet/ShowOnlyToLoggedInUsers.js'); // // // // ShowOnlyToLoggedInUsers.js // // This script will first check to see if the user is logged in. // If the user is logged in, //  the script will then show any HTML elements of the class "ShowOnlyToLoggedInUsers" // // Template:ShowOnlyToLoggedInUsers can be used to create such text.

if ( mw.config.get( 'wgUserId' ) != null) // If user is logged in { // get all elements in the class 'ShowOnlyToLoggedInUsers' var ElementsToShow=document.getElementsByClassName('ShowOnlyToLoggedInUsers'); // show those elements for(var i=0;i<ElementsToShow.length;i++) ElementsToShow[i].style.visibility="visible"; }