User:Sunny910910/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
// [[User:Lupin/popups.js]]
 
importScript('User:Lupin/popups.js');
 
//[[Category:Wikipedians who use RC script]]
addOnloadHook(function () {
    addPortletLink("p-interaction", wgArticlePath.replace(/\$1/, 'Special:Newpages'), "New pages",
        "n-newpages", "View a list of recently created pages");
});
addOnloadHook(function () {
    addPortletLink("p-interaction", wgArticlePath.replace(/\$1/, 'Special:Log/newusers'), "New users",
        "n-newusers", "List of New users");
});
addOnloadHook(function () {
    addPortletLink("p-interaction", wgArticlePath.replace(/\$1/, 'Wikipedia:Deletion today'), "Deletion",
        "n-deletiontoday", "Current deletions for today");
});
importScript('User:Lupin/recent2.js');
importScript('User:Sunny910910/WelcomeScript.js');
importScript('User:Animum/reset.js');
importScript('User:AndyZ/peerreviewer.js'); //[[User:AndyZ/peerreviewer.js]]
importScript('User:Ais523/topcontrib.js');
importScript('User:Ais523/watchlistnotifier.js');
importScript('User:Ais523/adminrights.js');
importScript('User:ais523/editcount.js'); //[[User:ais523/editcount.js]]
importScript('User:Sunny910910/WarningScript.js');
importScript('User:Sunny910910/UserpageWarning.js');
if(wgNamespaceNumber == 0 && wgAction == 'view' && wgEnableAPI) {
  var url = wgServer + wgScriptPath + '/api.php?action=query&prop=images|templates&callback=watchTemplatesImages&format=json&titles=' + encodeURIComponent(wgPageName);
  var scriptElem = document.createElement('script');
  scriptElem.setAttribute('src',url);
  scriptElem.setAttribute('type','text/javascript');
  document.getElementsByTagName('head')[0].appendChild(scriptElem);
  var imagesHere = new Array();
  var templatesHere = new Array();
  addOnloadHook(function() {
    addPortletLink('p-cactions','javascript:watchTemplatesImagesDo()','Watch All','ca-watchall','Watch all templates and images in this page');
  });
}
 
function watchTemplatesImages(obj) {
  if(!obj['query'] || !obj['query']['pages'] || !obj['query']['pages'][wgArticleId]) return
  imagesHere = obj['query']['pages'][wgArticleId]['images'];
  templatesHere = obj['query']['pages'][wgArticleId]['templates'];
  if(!imagesHere) imagesHere = [];
  if(!templatesHere) templatesHere = [];
}
 
function watchTemplatesImagesDo() {
  //half-assed watchlist/addendum-generator thing
  var cs = document.getElementById('contentSub');
  if(!cs) return;
  var wall = document.createElement('div');
  wall.style.backgroundColor = '#bbffbb';
  wall.style.padding = '8px';
  wall.appendChild(document.createTextNode('WATCH ALL: Please copy the text in the textarea below to your '));
  var wlink = document.createElement('a');
  wlink.setAttribute('href',wgServer + wgScript + '?title=Special:Watchlist/raw');
  wlink.appendChild(document.createTextNode('Raw watchlist'));
  wall.appendChild(wlink);
  var wlta = document.createElement('textarea');
  wlta.setAttribute('id','wlta');
  wlta.setAttribute('readonly','readonly');
  wlta.style.height = '6em';
  wlta.style.backgroundColor = '#fff6dd';
  for(var i=0;i<imagesHere.length;i++) {
    wlta.value += imagesHere[i].title + '\n';
  }
  for(var i=0;i<templatesHere.length;i++) {
    wlta.value += templatesHere[i].title + '\n';
  }
  wall.appendChild(wlta);
  cs.appendChild(wall);
}