User:Humus sapiens/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.
/* <pre> more at Wikipedia:WikiProject User scripts/Scripts */
 
/* Takes the wikipage "page" and includes its raw text as javascript. */
function import_module(page){
    if( document.createElement && document.childNodes ) {
        var url = 
            'http://en.wikipedia.org/w/index.php?title=' + 
            page.replace(/ /g, "_") + 
            '&action=raw&ctype=text/javascript&dontcountme=s';
        var scriptElem = document.createElement('script');
        scriptElem.setAttribute('src',url);
        scriptElem.setAttribute('type','text/javascript');
        document.getElementsByTagName('head')[0].appendChild(scriptElem);
    }
}
 
/* Helpers */
import_module('Wikipedia:WikiProject User scripts/Scripts/Add tab');
import_module('Wikipedia:WikiProject User scripts/Scripts/Add LI link');
import_module('Wikipedia:WikiProject User scripts/Scripts/addLink');
/* Scripts */
import_module('Wikipedia:WikiProject User scripts/Scripts/Replace');
import_module('Wikipedia:WikiProject User scripts/Scripts/Revert tools');
import_module('Wikipedia:WikiProject User scripts/Scripts/Autolink');
import_module('MediaWiki:WikiProject User scripts/Scripts/Compare link.js');
 
// Edit tools for the vandal whack-a-mole game
// [[User:Kbh3rd/whackamole.js]] - please include this line
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Kbh3rd/whackamole.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// [[User:Henrik/sandbox/google-search]] (please include this line)
function install_search() {
 document.getElementById('searchBody').innerHTML='<div>'+
 '<FORM method=get action="http://www.google.com/search">'+
 '<input type=hidden name="ie" value="UTF-8" /><input type=hidden name="oe" value="UTF-8" />'+
 '<INPUT id="searchInput" name="q" type="text" accesskey="f" value="" />'+
 '<input type="hidden" name="domains" value="en.wikipedia.org" />'+
 '<input type=radio name=sitesearch value="">Web'+
 '<input type=radio name=sitesearch value="en.wikipedia.org" checked />WP'+
 '<INPUT type="submit" name="btnG" VALUE="Google Search"  /></FORM></div>';
 }
addOnloadHook(install_search);
 
// This will add an [edit top] link at the top of all pages except preview pages
// by User:Pile0nades
// Add an [edit top] link to pages
addOnloadHook(function () {
  // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/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-right:15px;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
  if(window.location.href.indexOf("&action=edit") == -1)
    document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
  if(window.location.href.indexOf("&action=edit&section=0") != -1)
    document.getElementById("wpSummary").value = "/* Intro */ ";
 });
 
// Code originally by [[User:Raylu|raylu]]
// Modified by [[User:Moeron]]
// This script adds a "subst:welcome2" tab to the top of User pages
// when in edit mode.
 
function dowelcome2() {
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n{' + '{' + 'subst' + ':' + 'welcome2' + '}' + '}' + ' ' + '~' + '~' + '~' + '~';
  document.editform.wpSummary.value = 'Welcome to Wikipedia!';
  document.editform.wpMinoredit.checked = false;
  document.editform.submit();
}
 
function addwelcome2() {
  addTab("javascript:dowelcome2()", "subst:welcome2", "ca-welcome2", "subst:welcome2", "");
  akeytt();
}
 
addOnloadHook(function() {
  if (document.title.indexOf("User:") != -1 || document.title.indexOf("User talk:") != -1) {
  addOnloadHook(addwelcome2);
  }
});
 
// install [[User:Cacycle/wikEd]] in-browser text editor
//document.write('<script type="text/javascript" src="'
//+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
//+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//var wikEdFrameCSS = [];
//wikEdFrameCSS['.wikEdLinkName'] = 'color: blue; font-weight: bold;';
//wikEdFrameCSS['.wikedFrameBody'] = 'background-color: #e0e7f7;';
 
/* </pre> */