User:Larbot/monobook.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

//<pre><nowiki>
//---------------------------------------------------------------

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Script loading function by Quarl (http://en.wikipedia.org/wiki/User:Quarl)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}

// **** Add generic tab ****

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

// there is a version of the above in User:Voice_of_All/Addtabs/monobook.js

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '#';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}
//First loads
//Helper tools for tabs

// Helper tools (addtabs mandatory for other functions)
winc('[[User:Voice_of_All/Addtabs/monobook.js]]');  

// UTC clock
winc('[[User:Voice_of_All/UTCclock.js]]'); 

// Deletion
winc('[[User:Voice_of_All/Deletion/monobook.js]]'); 

// Replace txt
winc('[[User:Voice_of_All/replacetxt.js]]'); 

// Admin protection tools
winc('[[User:Voice_of_All/Protection/monobook.js]]'); 

//DYK functions
winc('[[User:Larbot/DYK/monobook.js]]');

// History analysis: 
// Analyzes a page history when "statistics" tab is clicked. Shows a whole range of useful data. 
// Also gives quick edit summary %  usage and namespace % based on all edits appearing on the 
// contributions page. taken from [[User:Voice_of_All/History/monobook.js]]

// History tools
winc('[[User:Voice_of_All/History/monobook.js]]'); 

// AfD helper (vote automation tool)

/**** afd helper ****/

winc('[[User:Jnothman/afd_helper/script.js]]'); 

/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */

afdh_signature='~~'+'~~';

// misc tabs cribbed from [[/User:Pschemp/monobook.js]] who cribbed it from somewhere else

winc('[[User:Larbot/moretabs/monobook.js]]')


//live-preview stuff
wpUserName = 'Lar';
wpShowImages = true;

winc('[[User:Pilaf/livepreview.js]]'); 

//document.write('<script type="text/javascript" //src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//---------------------------------------------------------------
function URLEncoding(input)
      {
        var encodedInputString=escape(input);
        encodedInputString=encodedInputString.replace("+", "%2B").replace("+", "%2B").replace("+", "%2B");
        encodedInputString=encodedInputString.replace("/", "%2F").replace("/", "%2F").replace("/", "%2F");   
        encodedInputString=encodedInputString.replace("&","%26").replace("&","%26").replace("&","%26");     
        var outputurl=encodedInputString;
        return outputurl;
      }
//END


//---------------------------------------------------------------
/* like submitting the URL http://en.wikipedia.org/w/index.php?title={{{PAGENAME}}}&action=purge */

function addpurge() {
    ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}


//---------------------------------------------------------------
//Toolbox links
function changelinks() {
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'my Talk';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Change Prefs';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'My Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'My Contribs';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Log out';
}
function addtoolboxlinks() {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, '/wiki/Special:Log/newusers', 'New users', '');
    addlilink(tb, '/wiki/Category:Candidates_for_speedy_deletion', 'Speedy deletions', '');
    addlilink(tb, '/wiki/Wikipedia:Administrator_intervention_against_vandalism', 'Vandalism', '');
    addlilink(tb, '/wiki/WP:RfPP', 'Protection requests', '');
    addlilink(tb, '/wiki/WP:PP', 'Protected pages', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard', 'Noticeboard', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard/3RR', '3RR violations', '');
    addlilink(tb, '/wiki/Wikipedia:Template messages/User_talk_namespace', 'Talk templates', '');
    addlilink(tb, '/wiki/Wikipedia:Template_messages', 'Templates', '');
    addlilink(tb, '/wiki/WP:CSD', 'SD criteria', '');
    addlilink(tb, '/wiki/Special:Log', 'Log', '');
    addlilink(tb, '/wiki/Special:Log/delete', 'Delete log', '');
    addlilink(tb, '/wiki/Special:Log/block', 'Block log', '');
    addlilink(tb, '/wiki/Special:Ipblocklist', 'IPBlocklist', '');
    addlilink(tb, '/wiki/Category:Request for Unblock', 'Unblock requests', '');
    addlilink(tb, '/wiki/Category:Wikipedia spam cleanup', 'Spam cleanup', '');
}
//END

// ======== USER TABS =======
 addOnloadHook(function() {
   if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history
      return;
   }
   if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) {
      username_a = document.URL.match(/:.*:(.*)/);
      username=username_a[1];
      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "log", "ca-blog", "block log", "");
      addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "info", "ca-kate", "user info", "");
   }
 });

//************

//************
//LAST DIFF TAB
function lastdiff() 
    {
    if (document.title.indexOf("Editing ") != -1)
    {return;}
    z=document.getElementById("content").childNodes;
    for (var n=0;n<z.length;n++) { 
      if (z[n].className=="firstHeading") 
      {
  var pname=document.title.split(' - ')[0].replace(/&/g,'%26').replace(/\\+/g, '%2B');
      }
    }
addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", "Last", "ca-diff", "Show most recent diff", "");
}

// This will add an [edit top] link at the top of all pages except preview pages
function addtoplink()
{
var edittop = '<span style="color:black;">[</span>edit top<span style="color:black;">]</span>';
  // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("w/index.php?title=Special:") != -1) return;
  if(document.title.indexOf("Main Page") != -1) return;

  // get the page title
  var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); 

  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:35px;margin-top:3px;"><a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">' + edittop + '</a></div>';

  // insert divContainer into the DOM before the h1
if (document.getElementById("content") !=undefined) {
  document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);}
}
//END

//************
//MAIN
//************

addOnloadHook(Mainfast)
function Mainfast() 
{
    changemovetab();
    changelinks();
    addpurge();
    addtoolboxlinks();
    add_more_tabs();

}

window.onload = Main;
function Main() 
{
    addtoplink();
    LivePreviewInstall();
    if(addSinceTab)
    {addSinceTab();}
}
//END
//************

//
Mvaluejsadmin = 'DMalak1';
Rvaluejsadmin = 'ERollenH1';
//
//************
//Slow load tools
//Admin rollback tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Specialadmin/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
// Script from [[User:MarkS/extraeditbuttons.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:MarkS/extraeditbuttons.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//New user log tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Admin warning tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Adminwarnings/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Delete tabs
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Deletion/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//************
//Google tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Google/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END

//Zocky's search box
winc('[[User:Zocky/SearchBox.js]]');

//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//Interiot's javascript edit counter

if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
winc('[[User:Interiot/Tool2/code.js]]');

//  document.write('<script type="text/javascript" src="' 
//    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
//    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); 
}

//************
//Lupin's tools
//************
//Filter changes live [[Category:VoA scripted admins]]
//[[User:Lupin/recent2.js]] - please include this line
winc('[[User:Lupin/recent2.js]]');

//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//[[User:Lupin/popupsdev.js]] - please include this line 
winc('[[User:Lupin/popupsdev.js]]');

//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

popupShortcutKeys=true; // optional: enable keyboard shortcuts

// I am an admin so do use this
popupAdminLinks=true;   // optional: enable admin links [[Category:VoA scripted admins]]
popupSubpopups=false;
popupStructure='shortmenus';
popupDelay=1.0;          // optional: time in s before popup happens (slowed down from default of .5s
popupEditCounterTool='interiot';  // other value is 'kate' but I prefer interiot's as it has more features
popupOnEditSelection=false; // I do not want popups for links that I select while editing.
popupFixDabs=true;          // I do want to be able to fix disambigs

popupExtendedRevertSummary='Revert to version $1 by $2 using [[:en:Wikipedia:Tools/Navigation_popups|popups]]';


//

//Change move tab name
function changemovetab()
{
if (document.title.indexOf("Talk:") == -1 && document.title.indexOf("talk:") == -1 && document.title.indexOf("User:") == -1 && document.title.indexOf("MediaWiki:") == -1 && document.title.indexOf("Image:") == -1 && document.title.indexOf("Wikipedia:") == -1 && document.title.indexOf("Template:") == -1 && document.title.indexOf("Portal:") == -1 && document.title.indexOf("Help:") == -1 && document.title.indexOf("Main Page") == -1 && document.title.indexOf("Category:") == -1)
  {
  if(document.getElementById('ca-edit'))
  {document.getElementById('ca-edit').firstChild.innerHTML = 'Modify';}
  if(document.getElementById('ca-move'))
  {document.getElementById('ca-move').firstChild.innerHTML = 'Rename';}
  if(document.getElementById('ca-history'))
  {document.getElementById('ca-history').firstChild.innerHTML = 'Revisions';}
  }
if (document.title.split(' - ')[0].split(".js")[1] != undefined)
  {
  if (document.title.split(' - ')[0].split(".js")[1] != undefined)
     {
      if(document.getElementById('ca-nstab-main'))
      {
      document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Javascript';
      }  
      else if(document.getElementById('ca-nstab-user'))
      {
      document.getElementById('ca-nstab-user').firstChild.innerHTML = 'User JS';
      } 
      else if(document.getElementById('ca-nstab-mediawiki'))
      {
      document.getElementById('ca-nstab-mediawiki').firstChild.innerHTML = 'MediaWiki JS';
      }  
    }
  }
}
//END


//************
//</nowiki></pre>[[Category:Wikipedians who use VoA script |Larbot]]