User:Linuxbeak/monobook.js

function addPurgeLink() { // Adds a "Purge page" link to the toolbox

  // remove "action" variable from the URL and insert new one

  myURL = window.location;
  var myGetVars = myURL.search.substring(1,myURL.search.length).split("&");
  var myCleanGetVars = Array(); 
  for (i=0;i<myGetVars.length;++i) {
    if (myGetVars[i] && myGetVars[i].substr(0,6) != "action") {
      myCleanGetVars.push(myGetVars[i]);
    }
  }
  myCleanGetVars.push("action=purge");
  var myNewGetVars = "?" + myCleanGetVars.join("&");
  myURLString = myURL.protocol + "//" + myURL.hostname + myURL.pathname + myNewGetVars + myURL.hash;

  addToToolbox('Purge page', myURLString, 'Purge this page', 't-purge');
}

function addEditCountLink() { // Add "Count User edits" link to toolbox
  if (window.location.pathname.indexOf('index.php') > 0) { // GET mode
    myTrigger = window.location.search;
  } else { // Path mode
    myTrigger = window.location.pathname;
  }
  if (myTrigger.indexOf('User:') > 0) { // We're in User space
    myUName = extractUName('User:', myTrigger);
  } else if (myTrigger.indexOf('User_talk:') > 0) { // We're in User_talk space 
    myUName = extractUName('User_talk:', myTrigger);
  } else if (myTrigger.indexOf('Special:Contributions') > 0) { // We're viewing contributions
    myUName = extractUName('Special:Contributions/', myTrigger); 
  } else { // Bail out
    return false;
  }
  myEscapedUName = myUName.replace(/_/, "+");
  myClearUName = myUName.replace(/_/, " ");
  myURLString = 'http://kohl.wikimedia.org/~kate/cgi-bin/count_edits.cgi?user='+ myEscapedUName +'&dbname=enwiki';
  addToToolbox('Count user edits', myURLString, 'Count edits by ' + myClearUName, 't-ucount');
  myBlockString = 'http://en.wikipedia.org/w/index.php?title=Special:Blockip&ip='+myClearUName;
  addToToolbox('Block user', myBlockString, 'Block ' + myClearUName, 't-ublock');
}

function addCrossWPSearchLink() { // Search article in other WPs link to toolbox
  if (window.location.pathname.indexOf('index.php') > 0) { // GET mode
    myTrigger = window.location.search;
  } else { // Path mode
    myTrigger = window.location.pathname;
  }
  if (
myTrigger.indexOf('User:') < 0 && 
myTrigger.indexOf('User_talk:') < 0 && 
myTrigger.indexOf('Wikipedia:') < 0 && 
myTrigger.indexOf('Wikipedia_talk:') < 0 && 
myTrigger.indexOf('Category:') < 0 && 
myTrigger.indexOf('Category_talk:') < 0 && 
myTrigger.indexOf('Template:') < 0 && 
myTrigger.indexOf('Template_talk:') < 0 && 
myTrigger.indexOf('Image:') < 0 && 
myTrigger.indexOf('Image_talk:') < 0 && 
myTrigger.indexOf('Help:') < 0 && 
myTrigger.indexOf('Help_talk:') < 0 && 
myTrigger.indexOf('MediaWiki:') < 0 &&
myTrigger.indexOf('Special:') < 0 &&
myTrigger.indexOf('MediaWiki_talk:') < 0 ) { // We're in Article space
    myArticleName = extractUName('/wiki/', myTrigger);
  } else if (myTrigger.indexOf('Talk:') > 0) { // We're in Talk space 
    myArticleName = extractUName('Talk:', myTrigger);
  } else { // Bail out
    return false;
  }

  myURLString = 'http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=30&minor=1&search='+ myArticleName;

  addToToolbox('Other Wikipedias', myURLString, 'Look up ' + myArticleName + 'in other language Wikipedias', 't-uotherwp');
}

function StubConvert() {

document.getElementsByName("wpSummary")[0].value = "{" + "{Egypt-stub}} => {" + "{Ancient-Egypt-stub}} as per [[WP:SFD]]";
document.getElementsByName("wpMinoredit")[0].checked = "checked";
oldArticleText = document.getElementsByName("wpTextbox1")[0].value;
newArticleText = oldArticleText.replace(/\{\{[E|e]gypt-stub\}\}/, "{" + "{Ancient-Egypt-stub}}");
document.getElementsByName("wpTextbox1")[0].value = newArticleText;

document.editform.submit();

}

function addStubConvLink() {
  addToToolbox('Ancient Egypt convert', 'javascript:StubConvert();', 'Ancient Egypt convert', 't-AEConv');
}

function extractUName(namespace, myString) {
  myCleanedString = myString.substring(myString.indexOf(namespace) + namespace.length,myString.length);
  if (myCleanedString.indexOf('/') > 0) {
    mySliceEnd = myCleanedString.indexOf('/');
  } else {
    mySliceEnd = myCleanedString.length;
  }
  myCleanerString = myCleanedString.substring(0,mySliceEnd);
  return myCleanerString;
}

function addToToolbox(label, link, title, id) { // Create new child node of the toolbox object

  var myLinktext = document.createTextNode(label);
  var myLink = document.createElement("a");
  myLink.href = link;
  myLink.title = title;
  myLink.appendChild(myLinktext);
  var myListItem = document.createElement("li");
  myListItem.id = id;
  myListItem.appendChild(myLink);
  document.getElementById('p-tb').getElementsByTagName("ul")[0].appendChild(myListItem);

}

function reformatMyPage() { // execute all formatting functions...
  addPurgeLink();
  addEditCountLink();
  addCrossWPSearchLink();
//  addStubConvLink();
}

// when the page is loaded

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

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.