Jump to content

User:Mets501/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mets501 (talk | contribs) at 21:24, 23 June 2006 (testing). 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.
//<pre>
if (navigator.product == 'Gecko' )
{
// [[User:Lupin/popups.js]]

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>');

popupFixDabs=true;

/* Move top tabs inside body content */

addOnloadHook(function () {
    content = document.getElementById("column-content");    // Find the main content column

    footer = document.getElementById("footer");  // Find the footer
    footer.parentNode.removeChild(footer);    // Remove the footer from the global wrapper
    content.appendChild(footer);    // Place footer at the end of the content column;

    tabs = document.getElementById("p-cactions");   // Find the top tab list
    tabs.parentNode.removeChild(tabs);    // Remove the tab list from the side column
    content.insertBefore(tabs,content.firstChild);    // Place tab list at the beginning of the content column
});

//Interiot's javascript edit counter
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  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>'); }

 //  Add a "Kate" link to your monobook "personal menu" list at the very
 //  top of the page.
 //
 //  Indicate where you would like "Kate" to appear:
 //    pt-userpage, pt-mytalk, pt-preferences,
 //    pt-watchlist, pt-mycontris, pt-logout
 //

gsKateInsertBefore = 'pt-mycontris'; // leave blank to append after "logout"

 //

function KateLink() {

 var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;

 var li = document.createElement( 'li' );
   li.id = 'pt-kate';

   var a = document.createElement( 'a' );
     a.appendChild( document.createTextNode( 'My edit count' ) ); // eh, the css makes the text lowercase
     a.href = 'http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=' + user;

   li.appendChild( a );

 if ( ! gsKateInsertBefore ) // append to end (right) of list
 {  document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
 }
 else
 {  var before = document.getElementById( gsKateInsertBefore );
     before.appendChild( li, before );
 }

}

  if ( window.addEventListener ) window.addEventListener( 'load', KateLink, false );

else if ( window.attachEvent ) window.attachEvent ( 'onload', KateLink );

 //  Add a "Recent Changes" link to your monobook "personal menu" list at the very
 //  top of the page.
 //
 //  Indicate where you would like "Changes" to appear:
 //    pt-userpage, pt-mytalk, pt-preferences,
 //    pt-watchlist, pt-mycontris, pt-logout
 //

gsChangesInsertBefore = 'pt-watchlist'; // leave blank to append after "logout"

 //

function ChangesLink() {

 var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;

 var li = document.createElement( 'li' );
   li.id = 'pt-changes';

   var a = document.createElement( 'a' );
     a.appendChild( document.createTextNode( 'Recent changes' ) ); // eh, the css makes the text lowercase
     a.href = 'http://en.wikipedia.org/w/index.php?hideliu=1&title=Special%3ARecentchanges&namespace=0';

   li.appendChild( a );

 if ( ! gsChangesInsertBefore ) // append to end (right) of list
 {  document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
 }
 else
 {  var before = document.getElementById( gsChangesInsertBefore );
     before.appendChild( li, before );
 }

}

  if ( window.addEventListener ) window.addEventListener( 'load', ChangesLink, false );

else if ( window.attachEvent ) window.attachEvent ( 'onload', ChangesLink );

 function tnaddlilink(url, name)
 {
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

  var li = document.createElement('li');
  li.appendChild(na);
  return li;
 }
  
 function testn(number)
 {
  var page = prompt("Vandalism to which article?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + number + "-n|" + page + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Vandalism to [[" + page + "]] - warning " + number;
  f.submit();
 }
 
 function wA() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "welcome-anon-from|Where" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Welcome to Wikipedia!";
  f.submit();
 }
 
 function wap() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:Where/pwelcome" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Use preview; also, welcome!";
  f.submit();
 }
 
// This adds the warning template tabs to easily add them to user talk pages

 function es() {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "==Edit summaries==\n{{subst:" + "Edit summary" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Please use edit summaries";
  f.submit();
 }
 
 function add_testn_tabs()
 {
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Only add for pages with "Editing User talk:" somewhere in the title
  if (document.title.indexOf("Editing User talk:") != -1)
    {
      tabs.appendChild(tnaddlilink('javascript:es()', "Use edit summaries"));
      tabs.appendChild(tnaddlilink('javascript:testn("test1")',"Test 1"));
      tabs.appendChild(tnaddlilink('javascript:testn("test1a")',"Test 1 (blanking)"));
      tabs.appendChild(tnaddlilink('javascript:testn("test2")',"Test 2"));
      tabs.appendChild(tnaddlilink('javascript:testn("test2a")',"Test 2 (blanking)"));
      tabs.appendChild(tnaddlilink('javascript:testn("test3")',"Test 3"));
      tabs.appendChild(tnaddlilink('javascript:testn("test4")',"Test 4"));
      tabs.appendChild(tnaddlilink('javascript:testn("bv")',"Blatant vandalism"));
      tabs.appendChild(tnaddlilink('javascript:testn("obscene")',"Obscene"));
      tabs.appendChild(tnaddlilink('javascript:testn("joke")',"Joke"));
      tabs.appendChild(tnaddlilink('javascript:testn("welcomenpov")',"Welcome (NPOV)"));
      tabs.appendChild(tnaddlilink('javascript:wA()',"Welcome (anon)"));
      tabs.appendChild(tnaddlilink('javascript:wap()',"Welcome (use preview)"));
 }}
addOnloadHook(add_testn_tabs);


function addOldids(){
    var re=/index[.]php[?]title=[^&]*&oldid=(\d+)$/;
    var len=document.links.length;
    for (var i=0; i<len; ++i) {
        var a=document.links[i];
        if (re.test(a.href)) {
            var m=a.href.match(re);
            a.innerHTML += ' (' + m[1] + ')';
        }
    }
}
// for testing from monobook.js: 

if (window.location.href.indexOf("&action=history") != -1)
{
addOnloadHook(addOldids);
}

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

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

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

//

// My own edit top

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];
    return addlilink(tabs, url, name, id, title, key)
};

function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") return z[n].textContent;
  };
}

if (document.title.indexOf("Editing ") == -1) {
addOnloadHook(
  function() { 
    addTab("http://en.wikipedia.org/w/index.php?title="+getPname()+"&action=edit&section=0", "edit top", "ca-edittop", "Edit top", "");
  }
);
}

//

}

if (navigator.product != 'Gecko' ) { 
/**** afd helper ****/
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
  'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

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