Jump to content

User:TomasBat/Random Smiley Script

From Wikipedia, the free encyclopedia

This is a random smiley script by ais523. By clicking a simple link, you can automatically award a random user with the random smiley award. Just follow the instructions below for it to work:

//Random smiley script. By [[User:ais523]], based on the suggestion by [[User:TomasBat]].
addOnloadHook(function(){
  if(document.referrer.indexOf("RandomSmileyGenerator") != -1 &&
     wgNamespaceNumber == 2 && wgTitle.indexOf("/") == -1 &&
     wgPageName.indexOf(wgUserName) == -1)
  {
    //we're trying to give a random smiley
    location.href=wgServer+wgScriptPath+"/index.php?title=User_talk:"+
      encodeURIComponent(wgTitle)+"&action=edit&section=new&randomsmiley=1";
  }
  else if(document.referrer.indexOf("RandomSmileyGenerator") != -1 &&
     wgNamespaceNumber == 2 && location.href.indexOf("RandomSmileyGenerator") == -1 &&
     wgPageName.indexOf(wgUserName) == -1)
  {
    alert("This seems to be a user subpage, so there's no point in smiling at it. " +
          "Why not go back and try again?");
  }
  else if(location.href.indexOf("&randomsmiley=1")!=-1)
  {
    document.editform.wpSummary.value="Random Smiley Award";
    document.editform.wpTextbox1.value="{"+"{subst:User:Elipongo/SmileyAward2}} ~~"+"~~";
    document.editform['wpPreview'].click(); //change to wpSave to save without a preview
  }
});
*[[Special:Random/User|Send a random user a random smiley!]]

==Usage== 
For this to work for you, follow the instructions [[User:TomasBat/Random Smiley Script|here]].
  • Click on the link "Send a random user a random smiley!". You can click on it as many times as you want.