User:Lar/backup/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.
/* Some of these tools are documented at [[User:Trilobite/Tools]]. */
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Script loading function by Quarl (http://en.wikipedia.org/wiki/User:Quarl)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}
 
// popups documented at [[User:Lupin]] and [[User:Lupin/Popups_testing]]
 
// [[User:Lupin/popupsdev.js]] - please include this line 
 
// uncomment to use dev version of popups
 
// document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// winc('[[User:Lupin/popupsdev.js]]');          // Popups for links
 
// [[User:Lupin/popups.js]]
 
// uncomment to use non dev version of popups
 
// 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>');
 
// repkaced with 
winc('[[User:Lupin/popups.js]]');          // Popups for links
 
popupDelay=1.0;          // optional: time in s before popup happens (slowed down from default of .5s
popupShortcutKeys=true;  // optional: enable keyboard shortcuts
popupEditCounterTool='interiot';  // other value is 'kate' but I prefer interiot's as it has more features
popupOnEditSelection=false; // I do not want popups for links that I select while editing.
popupFixDabs=true;          // I do want to be able to fix disambigs
//
 
// I am an admin so do use this
 
popupAdminLinks=true;   // optional: enable admin links
 
// for more options see [[Wikipedia:Tools/Navigation popups]]
// end popups section
 
//Edit buttons: (where did they go, by the way?
 
 
 
// winc('[[User:Zocky/PicturePopups.js]]');      // PicturePopups
// [[User:Zocky/PicturePopups.js]] - please include this line 
// see [[User:Zocky/Picture Popups]] for more info 
 
// winc('[[User:Zocky/SearchBox.js]]');          // Search the edit box
winc('[[User:Interiot/Tool2/code.js]]');      // Interiot's edit counter script
winc('[[User:Lupin/recent2.js]]');            // Anti-vandal tool
 
 
winc('[[User:Cactus.man/scripts/extraeditbuttons.js]]'); // Additional edit buttons
 
 
 
 
// History analysis: 
// Analyzes a page history when "statistics" tab is clicked. Shows a whole range of useful data. 
// Also gives quick edit summary %  usage and namespace % based on all edits appearing on the 
// contributions page. taken from [[User:Voice_of_All/History/monobook.js]]
 
// 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>');
 
// AfD helper (vote automation tool)
 
/**** 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]] */
 
afdh_signature='~~'+'~~';
 
/* SUPER tres useful edit summary forcing (as stolen from [[user:JzG]] who got it here: [[Wikipedia:WikiProject_User_scripts/Scripts/Force_edit_summary]] 
A LOT of users have had in this one, including [[User:Alphax]], [[User:Jnothman]], and [[User:Ambush Commander]] */
 
// misc functions from  [[User:Trilobite]]
 
function addlilink(tabs, url, name, id) {
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}
 
function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '#';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}
 
/* change the names of personal tools links and the edit tab */
function changelinks() {
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'Talk';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Prefs';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'Contribs';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Logout';
    if(document.getElementById('ca-edit'))
        document.getElementById('ca-edit').firstChild.innerHTML = 'edit';
}
 
/* like submitting the URL http://en.wikipedia.org/w/index.php?title={{{PAGENAME}}}&action=purge */
 
function addpurge() {
    ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}
 
/* does a subst and adds sig, for desired template */
function vandal(tmplt) {
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{subst:' + tmplt + '}} ~~'+'~~';
    txt.focus();
    txt = document.editform.wpSummary;
    txt.value = tmplt
    document.editform.wpWatchthis.checked = false;
}
 
/* add links to toolbox */
 
function addtoolboxlinks() {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, '/wiki/Category:Candidates_for_speedy_deletion', 'Speedy deletions', '');
//    addlilink(tb, '/wiki/Wikipedia:Votes_for_deletion/Old', 'VfD backlog', '');
    addlilink(tb, '/wiki/Wikipedia:Vandalism_in_progress', 'Vandalism', '');
//    addlilink(tb, '/wiki/Special:Blockip', 'Block IP', '');
    addlilink(tb, '/wiki/Wikipedia:Village_pump_%28all%29', 'Village pump', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard', 'Noticeboard', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard/Incidents', 'Incidents', '');
}
 
/* add tabs to warn vandals */
function morelinks() {
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(document.title.indexOf("Editing ") == 0) addlilink(tabs, 'javascript:replace()', 'replace', '');
    if(document.title.indexOf("Editing Image:") == 0) addlilink(tabs, 'javascript:unverified()', 'tag', '');
    if(document.title.indexOf("Editing User talk:") == 0) {
        addlilink(tabs, 'javascript:vandal("test")', 't1', '');
        addlilink(tabs, 'javascript:vandal("test2")', 't2', '');
        addlilink(tabs, 'javascript:vandal("test2a")', 't2a', '');
        addlilink(tabs, 'javascript:vandal("test3")', 't3', '');
        addlilink(tabs, 'javascript:vandal("test4")', 't4', '');
        addlilink(tabs, 'javascript:vandal("test5")', 't5', '');
        addlilink(tabs, 'javascript:vandal("spam")', 's1', '');
        addlilink(tabs, 'javascript:vandal("spam2")', 's2', '');
        addlilink(tabs, 'javascript:vandal("spam3")', 's3', '');
        addlilink(tabs, 'javascript:vandal("spam4")', 's4', '');
    }
}
 
 
/* add a replace tab in edit mode */
function replace() {
    var s = prompt("Search regexp?");
    if(s) {
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}
 
/* add an umverified image tag and comment to an image */
function unverified() {
    document.editform.wpSummary.value = 'needs a source and copyright tag - see [[Wikipedia:Image copyright tags]]';
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{unverified}}';
    txt.focus();
}
 
// End Trilobite's mods
 
//live-preview stuff
 
wpUserName = 'Lar';
wpShowImages = true;
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); 
 
//From User:JesseW/monobook.js
function addSinceTab() 
{
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if (window.location.href.indexOf("&limit=200&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(" - "));
       thetitle = thetitle.replace('&','%26').replace('&','%26').replace('&','%26').replace('&','%26');
       var l=addlilink(tabs, "/w/index.php?title="+thetitle+"&limit=200&action=history&gotosince=true", 'since', '');
       l.lastChild.title="Changes since I last edited";
    }
}
 
function do_since_I_last_edited() 
{
        var undefined;
	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 go = 'no';
        var username = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;
	var hists = document.getElementById('bodyContent').getElementsByTagName('li');
        var findcheck = document.getElementById('bodyContent');
	for (var n=0; n<hists.length; n++) 
          {
	  if (hists[n].getElementsByTagName('a')[3])
            {
	     if (hists[n].getElementsByTagName('a')[3].innerHTML == username)
               {
             hists[n].getElementsByTagName('input')[0].checked=true;
             if (n == 0){msg.replaceChild(document.createTextNode
			 ("You were the last person to edit this page!"),
			 msg.firstChild);; return;}
             location.href = hists[n].getElementsByTagName('a')[0].href;
             return;
               }
            }
	  else if (hists[n].getElementsByTagName('a')[2])
            {
	     if (hists[n].getElementsByTagName('a')[2].innerHTML == username)
               {
             if (n == 0){msg.replaceChild(document.createTextNode
			 ("You were the last person to edit this page!"),
			 msg.firstChild);;}
             return;
               }
            }
          }
	msg.replaceChild(document.createTextNode
			 ("You have not recently edited this page!"),
			 msg.firstChild);
}
//END
 
//
window.onload = Main;
function Main() {
 //   changelinks();
    addtoolboxlinks()
    addpurge();
    addSinceTab();
    morelinks();
    LivePreviewInstall();
    afd_helper();
}
 
// allow author tracking
// LivePreview: [[User:Pilaf/livepreview.js]] */
// Popups: [[User:Lupin/popups.js]] */
// AfD helper:  [[User:Jnothman/afd_helper/script.js]] */
//</nowiki>