User:LeyteWolfer/monobook.js

From Wikipedia, the free encyclopedia
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.
// Script from [[User:Lupin/recent2.js]]
mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

//
 // Edit tools for the vandal whack-a-mole game
 // [[User:Kbh3rd/whackamole.js]] - please include this line
 //
 mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Kbh3rd/whackamole.js' 
             + '&action=raw&ctype=text/javascript');


// [[User:Lupin/popups.js]]

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');
 popupDelay=1.5;

//Random smiley script. By [[User:ais523]], based on the suggestion by [[User:TomasBat]].
$(function(){
  if(document.referrer.indexOf("RandomSmileyGenerator") != -1 &&
     mw.config.get('wgNamespaceNumber') == 2 && mw.config.get('wgTitle').indexOf("/") == -1 &&
     mw.config.get('wgPageName').indexOf(mw.config.get('wgUserName')) == -1)
  {
    //we're trying to give a random smiley
    location.href=mw.config.get('wgServer')+mw.config.get('wgScriptPath')+"/index.php?title=User_talk:"+
      encodeURIComponent(mw.config.get('wgTitle'))+"&action=edit&section=new&randomsmiley=1";
  }
  else if(document.referrer.indexOf("RandomSmileyGenerator") != -1 &&
     mw.config.get('wgNamespaceNumber') == 2 && location.href.indexOf("RandomSmileyGenerator") == -1 &&
     mw.config.get('wgPageName').indexOf(mw.config.get('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:Smile}} ~~"+"~~";
    document.editform['wpPreview'].click(); //change to wpSave to save without a preview
  }
});