Misplaced Pages

User:DESiegel/monobook.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:DESiegel Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 22:19, 24 April 2007 view sourceDESiegel (talk | contribs)Extended confirmed users50,971 editsNo edit summary← Previous edit Revision as of 22:21, 24 April 2007 view source DESiegel (talk | contribs)Extended confirmed users50,971 editsNo edit summaryNext edit →
Line 1: Line 1:
// CSD AutoReason
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/search/?title=User:^demon/csd.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');


if(document.title.indexOf("My watchlist") == 0) unwatchlinks(); if(document.title.indexOf("My watchlist") == 0) unwatchlinks();



Revision as of 22:21, 24 April 2007

// CSD AutoReason
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/search/?title=User:^demon/csd.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');


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.indexOf('=');
    if (l.substring(0, n) == 'faketarget') {
      target = l.substring(n + 1);
    }
  }
  if (!target)
    return;
  form = document.getElementById('blockip');
  if (!form)
    return;
  input = form.getElementsByTagName('input');
  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');
    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);
}


// ] - please include this line 

// document.write('<script type="text/javascript" src="' 
//              + 'http://en.wikipedia.org/search/?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  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(" - ").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;">+'">edit top</a>]</div>';

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

}

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

   ta = ;
   var x = document.getElementById('ca-history');
   if(!x) return;
   if(x.children) x = x.children.href;
   else x = x.childNodes.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/search/?title=User:JesseW/monobook.js&oldid=20755510
function addSinceTab() {
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul');
    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, "/search/?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.getElementsByTagName("span").textContent==username) {
                document.location=hists.childNodes.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 = ;
       }
       else if(key)
       {
           ta = ;
       }
       else if(title)
       {
           ta = ;
       }
   }
   // 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');
   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.href)) {             // Find all the ones that link to history pages
                newUnwatchLink = document.createElement('a');
                newSeparator = document.createTextNode("; ");
                newUnwatchLink.href = x.href.match(/\/w\/.+?&/) + "action=unwatch";    // Replace the action=history with action=unwatch
                newUnwatchLink.innerHTML = "un";
                x.parentNode.insertBefore(newUnwatchLink, x.nextSibling);
                x.parentNode.insertBefore(newSeparator, x.nextSibling);             // Insert after the hist link with a semicolon
            }
        }
    }
 }

 /* CSD helper script follows */
 /* <pre><nowiki> */


 if (document.title.indexOf("Confirm delete") != -1) {
     var csdDeleteForm = {
				FillSelect:function(sel, arr){
					if(arr && arr.length>0){
						if(arr.length>1){
							var FirstOpt = new Option("CSD Reasons", "");
							// catches stupid IE error
							if(FirstOpt.innerHTML != "CSD Reasons"){
								FirstOpt.innerHTML = "CSD Reasons";
							}
							sel.appendChild(FirstOpt);
							sel.options.style.color = "gray"
						}
						sel.disabled = false;
						for(var i=0;i<arr.length;i++){
							var opt = new Option(arr.display, arr.value);
							// catches stupid IE error
							if(opt.innerHTML != arr.display){
								opt.innerHTML = arr.display;
							}
							sel.appendChild(opt);
						}
					}else{
						sel.options = new Option("No Options Available", "");
						// catches stupid IE error
						if(sel.options.innerHTML != "No Options Available"){
							sel.options.innerHTML = "No Options Available";
						}
						sel.disabled = true;
						return false;
					}
					return true;
				},
				ValueArray:[
					{"value":"]","display":"G1 - Nonsense"},
					{"value":"]","display":"G2 - Test Pages"},
					{"value":"]","display":"G3 - Pure Vandalism"},
					{"value":"]","display":"G4 - Recreated Deleted"},
					{"value":"]","display":"G5 - Banned User"},
					{"value":"]","display":"G6 - Housekeeping"},
					{"value":"]","display":"G7 - Author Request"},
					{"value":"]","display":"G8 - Talk Page"},
					{"value":"]","display":"G9 - Office Actions"},
					{"value":"]","display":"G10 - Attack Pages"},
					{"value":"]","display":"G11 - Advertising"},
					{"value":"]","display":"G12 - Copyright"},
					{"value":"]","display":"A1 - No Context"},
					{"value":"]","display":"A2 - Foreign Language"},
					{"value":"]","display":"A3 - No Content"},
					{"value":"]","display":"A5 - Transwikied"},
					{"value":"]","display":"A7 - Unremarkable"},
					{"value":"]","display":"R1 - Bad Target"},
					{"value":"]","display":"R2 - Crossnamespace"},
					{"value":"]","display":"R3 - Bad Typo"},
					{"value":"]","display":"I1 - Redundant"},
					{"value":"]","display":"I2 - Corrupt/Empty"},
					{"value":"]","display":"I3 - Improper License"},
					{"value":"]","display":"I4 - Lack of License"},
					{"value":"]","display":"I5 - Unused Unfree"},
					{"value":"]","display":"I6 - No Fair Use"},
					{"value":"]","display":"I7 - Invalid Fair Use"},
					{"value":"]","display":"I8 - On Commons"},
					{"value":"]","display":"C1 - Empty"},
					{"value":"]","display":"C2 - Speedy Rename"},
					{"value":"]","display":"C3 - Template"},
					{"value":"]","display":"U1 - User Request"},
					{"value":"]","display":"U2 - No User"},
					{"value":"]","display":"U3 - Fair Use Gallery"},
					{"value":"]","display":"T1 - Divisive"},
					{"value":"]","display":"P1 - Speedy Article"},
					{"value":"]","display":"P2 - Underpopulated"},
				],
				//**************************** attaching function *****************************************
				// got thIS super handi function from http://www.scottandrew.com he is pretty dang smart **
			        //*****************************************************************************************
				addEvent:function(obj, evType, fn, useCapture){
					//alert(obj);
					if (obj.addEventListener){
						obj.addEventListener(evType, fn, useCapture);
						return true;
					} else if (obj.attachEvent){
						var r = obj.attachEvent("on"+evType, fn);
						return r;
					} else {
						alert("Handler could not be attached");
					}
				}
			}
			function addSelectAfter(){
    				var obj = document.getElementById('wpReason');
    			        // create select using included array
				var sel = document.createElement("SELECT");
				csdDeleteForm .FillSelect(sel, csdDeleteForm .ValueArray);
				// name it
				sel.name = "csdOptions";
				sel.id = "csdOptions";
                                sel.style.marginLeft = "10px";
                                csdDeleteForm .addEvent(sel, "change", csdChangeBox, false);
				// check for next sibling and insert before it or at the end
				if(obj.nextSibling){
					obj.parentNode.insertBefore(sel,obj.nextSibling);
				}else{
					obj.parentNode.appendChild(sel);
				}
			}
			try{
				// add one on load
				csdDeleteForm.addEvent(window, "load", addSelectAfter, false);
			}catch(err){}
 }

 function csdChangeBox() {
                                                         var obj = document.getElementById('wpReason');
                                                         obj.value = document.getElementById('csdOptions').value;
                                                         }


 /* </nowiki><pre> */

 /* End CSD helper script */