User:Fisdof9/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.
//Self-Made Script
//Purger
addOnloadHook(function() {
  var title = wgPageName.replace("?", "%3F").replace("%","%25");
  if (wgCanonicalNamespace != "Special") {
    addPortletLink("p-cactions", wgServer + "/wiki/" + title + "?action=purge", "Purge", "ca-purgetab", "Purge this Page");
  }
});
//End Purger
//Redirect
addOnloadHook(function(){
  if (document.URL.lastIndexOf("&redir=1") != -1) {
    var target=prompt("Redirect to?","");    
      if (target){
        var other=prompt("Anything you want to add? (e.g. \{\{R from ?\}\})","");
        var message=prompt("Leave a message in the edit summary?","");
        if (other){
          document.editform.wpTextbox1.value = "#REDIRECT [[" + target + "]] " + other}
        else {
          document.editform.wpTextbox1.value = "#REDIRECT [[" + target + "]]"}
        if (message){
          document.editform.wpSummary.value="Redirect to [[" + target + "]] (" + message + ")"}
        else{
          document.editform.wpSummary.value="Redirect to [[" + target + "]]"}
        document.editform.wpMinoredit.checked="true"
        document.editform.wpPreview.click()}
      else {alert("No target specified")}}
  redirtab()
});
function redirtab() {
  if (wgCanonicalNamespace!="Special") {
  if (wgRestrictionEdit!="sysop"){
    var title=wgPageName.replace("?","%3F").replace("&","%26");
      addPortletLink("p-cactions",wgServer + wgScript + "?title=" + title + "&action=edit&redir=1","redirect","ca-redir","Redirect the page")}};
}
//End Redirect
//End Self-Made
 
// Add date and time to your monobook "personal menu" list at the very top of the page.
// Created by [[User:Mathwiz2020]]
 
// Indicate where you would like the time to appear:
// 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link)
insertBeforeNum = 7;
 
// Do NOT edit below this line unless you're experiened in javascript
insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout","");
insertBefore = insertBeforeArr[insertBeforeNum];
 
function makeTime()
{
  var li = document.createElement( 'li' );
  li.id = 'pt-time';
 
  var mySpan = document.createElement( 'span' );
  mySpan.appendChild( document.createTextNode( 'date and time' ) );
 
  li.appendChild( mySpan );
 
  if ( insertBefore )
  {
    var before = document.getElementById( insertBefore );
    before.appendChild( li, before );
  }
  else // append to end (right) of list
  {
    document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
  }
 
  getTime();
}
 
if      ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false );
else if ( window.attachEvent      ) window.attachEvent      ( 'onload', makeTime      );
 
function getTime()
{
    var time    = new Date();
    var date    = time.getUTCDate();
    var months  = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
        month   = months[time.getUTCMonth()];
    var year    = time.getUTCFullYear();
    var hours   = '0' + time.getUTCHours();
        hours   = hours.substr(hours.length-2, hours.length);
    var minutes = '0' + time.getUTCMinutes();
        minutes = minutes.substr(minutes.length-2, minutes.length);
    var seconds = '0' + time.getUTCSeconds();
        seconds = seconds.substr(seconds.length-2, seconds.length);
    var curTime = hours + ":" + minutes + ":" + seconds + ", " + date + " " + month + " " + year + " (UTC)";
    datePlace   = document.getElementById('pt-time').childNodes[0].childNodes[0];
                  datePlace.replaceData(0, datePlace.length, curTime);
    doTime      = window.setTimeout("getTime()", 1000);
}
//
// END TIME
 
// addPurge
addOnloadHook(function () {
    var hist; var url;
    if (!(hist = document.getElementById('ca-history') )) return;
    if (!(url = hist.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
                   'purge', 'ca-purge', 'Purge server cache for this page', '0');
});
 
importScript('User:Barticus88/WhatLinksHere.js');  // [[User:Barticus88/WhatLinksHere.js]]
 
//Please leave the following line
//[[user:Where/easy db]], maintained by [[User:MER-C]]
//<nowiki>Start db script
 
addOnloadHook(function()
{
  //check if called from deletion request
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    // does the page exist?
    if (wgCurRevisionId == false)
    {
      alert("The page has already been deleted.");
      return;
    }
    if (document.URL.lastIndexOf("&reason=off") != -1)
    {function csd(){
      var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3. For help, type h.","");
        if (type=="h"){help();csd()}
        else{if (type){
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{{db-" + type.toLowerCase() + "}}\n" + t.value;
      f.wpSummary.value = "Requesting speedy deletion ([[WP:CSD#" + type.toUpperCase() + "|CSD " + type.toUpperCase() + "]])";
      f.wpSave.click();
      return;}
            }}
    csd()
    }
    else if (document.URL.lastIndexOf("&reason=on") != -1)
    {
      var type = prompt("Enter reason for speedy deletion","reason");
      if (type == null)
        return;
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{{db|" + type + "}}\n" + t.value;
      f.wpSummary.value = "Requesting speedy deletion";
      f.wpSave.click();
      return;
    }
  }
  if (wgCanonicalNamespace == "Special")
    return;
 
  addPortletLink("p-cactions", "javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", "");
  addPortletLink("p-cactions", "javascript:easyDb(1)", "db (reason)", "ca-db1", "Request speedy deletion with reason", "");
});
 
function easyDb(n)
{
  var title = wgPageName.replace("&", "%26").replace("+", "%2B");
  if (n == 0)
    location.replace(wgServer + wgScript + "?&action=edit&fakeaction=huff&reason=off&title=" + title);
 
  if (n == 1)
    location.replace(wgServer + wgScript + "?&action=edit&fakeaction=huff&reason=on&title=" + title);
}
 
function help(){
var ns=wgCanonicalNamespace
var SDC="Speedy Deletion Criteria\:\n"
var G="GENERAL\n" + 
"G1: Nonsense\n" + 
"G2: Test page\n" + 
"G3: Vandalism\n" + 
"G4: Re-creation of deleted material\n" + 
"G5: Created by banned user while banned\n" + 
"G6: Housekeeping, maintenence\n" + 
"G7: Author request\n" + 
"G8: Orphan talk page\n" + 
"G9: Office actions\n" + 
"G10: Attack page\n" + 
"G11: Advertising\n" + 
"G12: Copyright infringement\n"
var A="ARTICLES\n" + 
"A1: No context\n" + 
"A2: Foreign language\n" + 
"A3: No content\n" + 
"A4: (merged with A3)\n" + 
"A5: Transwikied\n" + 
"A6: (superseded by G10)\n" + 
"A7: No indication of importance;not notable\n" + 
"A8: (superseded by G12)\n"
var U="USER\n" +
"U1: User Request\n U2:Userpage of nonexistent user\n U3:Non-free galleries\n"
var T="TEMPLATE\n" +
"T1: divisive\/inflammatory\n T2: blatant misrepresentations of policy"
if (ns==""){
alert(SDC+G+A)}
else{
if (ns=="User"||ns=="User talk"){
alert (SDC+G+U)}
else{
if (ns=="Template"){
alert(SDC+G+T)}
else{
alert(SDC+G)}
}}}
//</nowiki>End db script
 
importScript('User:Tra/userwatchlist.js'); //[[User:Tra/userwatchlist.js]]
 
// Please leave the following line
// [[user:Where/usertabs]]
 
addOnloadHook(function() {
  if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history
     return;
  if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
     var username = encodeURIComponent( wgTitle );
     addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions");
     addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "Edit count", "ca-editcount", "Edit count from Interiot's Tool1");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user");
  }
});
 
//