Jump to content

User:DESiegel/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DESiegel (talk | contribs) at 22:34, 24 April 2007 (rv). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
if(document.title.indexOf("My watchlist") == 0) unwatchlinks();

// -----------------------------------------------------------------------------
// Übergodmode Monobook skin
// (c) 2005 Sam Hocevar <sam@zoy.org>
// $Id: ubergodmode.js 886 2005-05-14 23:56:48Z sam $
// -----------------------------------------------------------------------------

var blocklink = 'Block this user';

// -----------------------------------------------------------------------------
// Our nice Block functions
// -----------------------------------------------------------------------------
function PerformBlock() {
  var l, target = '';
  // Look for '&faketarget=XXX' in URL
  url = location.pathname;
  l = location.search.substring(1).split('&');
  for (i = 0; i < l.length; i++) {
    var n = l[i].indexOf('=');
    if (l[i].substring(0, n) == 'faketarget') {
      target = l[i].substring(n + 1);
    }
  }
  if (!target)
    return;
  form = document.getElementById('blockip');
  if (!form)
    return;
  input = form.getElementsByTagName('input')[0];
  input.value = target;
}

// -----------------------------------------------------------------------------
// Add block buttons to the page
// -----------------------------------------------------------------------------
function AddBlockButtons() {
  var l, article = '', vandal;
  // Add 'block' links to a diff page
  l = document.getElementById('t-emailuser');
  if (l) {
    clone = l.cloneNode(true);
    l.id = 't-blockuser';
    a = clone.getElementsByTagName('a')[0];
    a.href = a.href.replace(/Special:Emailuser/, 'Special:Blockip');
    a.href = a.href.replace(/target=/, 'faketarget=');
    a.innerHTML = blocklink;
    l.parentNode.insertBefore(clone, l.nextSibling);
  }
}

// -----------------------------------------------------------------------------
// Modify the page once it is loaded
// -----------------------------------------------------------------------------
if (window.addEventListener) {
  window.addEventListener("load", PerformBlock, false);
  window.addEventListener("load", AddBlockButtons, false);
} else if (window.attachEvent) {
  window.attachEvent("onload", PerformBlock);
  window.attachEvent("onload", AddBlockButtons);
}


// [[User:Lupin/popups.js]] - please include this line 

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

// popupAdminLinks=true;   // optional: enable admin links
// popupStructure='fancy'; // links in popup itself
// popupFixRedirs=true;
// popupFixDabs=true;


//function MODULE_NAME(){
//    MODULE_CODE;
//}

//if (window.addEventListener) window.addEventListener("load", MODULE_NAME, false);
//else if (window.attachEvent) window.attachEvent("onload", MODULE_NAME);

// 

// This will add an [edit top] link at the top of all pages except preview pages // by 


setTimeout("editTopLink()", 0) // this is equivalent of onload 
function editTopLink() {

   // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("w/index.php?title=Special:") != -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-top:3px;">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">edit top</a>]</div>';

  // insert divContainer into the DOM before the h1
  document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);

}

// //Add purge to tabs 
function addPurge(){

   ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
   var x = document.getElementById('ca-history');
   if(!x) return;
   if(x.children) x = x.children[0].href;
   else x = x.childNodes[0].href;
   addTab(x.replace(/=history/, "=purge"), 'purge', 'ca-purge');
   akeytt();
}

if (window.addEventListener) window.addEventListener("load", addPurge, false); else if (window.attachEvent) window.attachEvent("onload", addPurge);

//

//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510
function addSinceTab() {
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       do_since_I_last_edited()
    }
    else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) {
       var thetitle=document.title.slice(0, String(document.title).indexOf(" - "));
       var l=addlilink(tabs, "/w/index.php?title="+thetitle+"&action=history&gotosince=true", 'since', '');
       l.lastChild.title="Changes since I last edited";
    }
}
function do_since_I_last_edited() {
        var csub=document.getElementById("contentSub");
        var msg=document.createElement("p");
        msg.appendChild(document.createTextNode
                        ("Parsing history... please wait..."));
        msg.className="error";
        csub.insertBefore(msg, csub.firstChild)

        var username=document.getElementById("pt-userpage").textContent;
        var hists=document.getElementById("pagehistory").childNodes;
        for (n=0;n<hists.length;n++) {
            if (hists[n].getElementsByTagName("span")[0].textContent==username) {
                document.location=hists[n].childNodes[1].href; 
                return;
            }
        }

        msg.replaceChild(document.createTextNode
                         ("You have not edited this page! (recently)"),
                         msg.firstChild);
}


if (window.addEventListener) window.addEventListener("load", addSinceTab, false);
else if (window.attachEvent) window.attachEvent("onload", addSinceTab);

// 




// **** Functions called by Modules ****

function addlilink(tabs, url, name, id, title, key){

   var na = document.createElement('a');
   na.href = url;
   na.appendChild(document.createTextNode(name));
   var li = document.createElement('li');
   if(id) li.id = id;
   li.appendChild(na);
   tabs.appendChild(li);
   if(id)
   {
       if(key && title)
       {
           ta[id] = [key, title];
       }
       else if(key)
       {
           ta[id] = [key, ];
       }
       else if(title)
       {
           ta[id] = [, title];
       }
   }
   // re-render the title and accesskeys from existing code in wikibits.js
   akeytt();
   return li;
}

//


function addTab(url, name, id, title, key){

   var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
   addlilink(tabs, url, name, id, title, key);
} //



// ================================================================
// Adds an unwatch link after each entry on the regular watchlist 
// (instead of requiring you to navigate to a separate page)
// by User:Omegatron
// Workaround for Bug 424 http://bugzilla.wikipedia.org/show_bug.cgi?id=424


function unwatchlinks(){
if(document.title.indexOf("My watchlist") == 0) {
    var x,i;
    x=document.links;                                           // Gets all the links on the page
        for(i=0;i<x.length;++i) {
            if (/action=history/.test(x[i].href)) {             // Find all the ones that link to history pages
                newUnwatchLink = document.createElement('a');
                newSeparator = document.createTextNode("; ");
                newUnwatchLink.href = x[i].href.match(/\/w\/.+?&/) + "action=unwatch";    // Replace the action=history with action=unwatch
                newUnwatchLink.innerHTML = "un";
                x[i].parentNode.insertBefore(newUnwatchLink, x[i].nextSibling);
                x[i].parentNode.insertBefore(newSeparator, x[i].nextSibling);             // Insert after the hist link with a semicolon
            }
        }
    }
}