// raw version at http://en.wikipedia.org/w/index.php?title=User:Jnothman/monobook.js&action=raw&ctype=text/javascript&dontcountme=s
//<pre>
/*document.write('<script type="text/javascript"' +
'src="http://sam.zoy.org/wikipedia/godmode-light.js"></script>');*/
/**** afd helper ****/
importScript('User:Jnothman/afd_helper/script.js');
/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */
afdh_summaryprompt = false;
// [[User:Lupin/popups.js]] - please include this line
//simplePopups = true;
popupShortcutKeys = true;
// more options at http://en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups
//importScript('User:Lupin/popups.js');
// Live Preview customization (from User:Pilaf/Live_Preview),
// edit this to your own liking.
wpUserName = 'jnothman'; // User name to display in signatures
wpShowImages = true; // Enable downloading and displaying of images
// Include Live Preview...
importScript('User:Pilaf/livepreview.js');
/* This is to keep track of who is using the Live Preview: [[User:Pilaf/livepreview.js]] */
//************************************ Purge cache tab *****************************
//From http://en.wikipedia.org/w/index.php?title=User:Trilobite/Tools&oldid=17855224
function addPurgeTab() {
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');
}
//********************************* Show Last Diff *********************************
//From User:JesseW/monobook.js
function doLastDiff() {
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") {
var pname=textContent(z[n]);
};
};
var nurl="http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev";
document.location=nurl
}
//************************************ Changes since I last edited ****************************
//From User:JesseW/monobook.js
function addSinceTab() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
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, "/w/index.php?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=textContent(document.getElementById("pt-userpage"));
var hists=document.getElementById("pagehistory").childNodes;
for (n=0;n<hists.length;n++) {
if (hists[n].getElementsByTagName && textContent(hists[n].getElementsByTagName("span")[0])==username) {
document.location=hists[n].childNodes[1].href;
return;
}
}
msg.replaceChild(document.createTextNode
("You have not edited this page! (recently)"),
msg.firstChild);
}
//****************** Are you sure you don't want a Summary? *******************************
//From http://en.wikipedia.org/w/index.php?title=User:ABCD/monobook.js&oldid=19452182
function addForceSummary(){
if(!/&action=edit/.test(window.location.href)) return;
if(/§ion=new/.test(window.location.href)) return;
if(!document.forms.editform) return;
document.forms.editform.wpSave.onclick = forceSummary;
}
function forceSummary(){
var form = document.forms.editform;
if(!form.wpSummary.value.replace(/^(\/\*.*\*\/)? *(.*) *$/,'$2')){
var r = prompt('Are you sure you want to submit without adding a summary?\nTo add a summary, type it in the box below:',form.wpSummary.value);
if(r == null) return false;
form.wpSummary.value = r;
}
return true;
}
//************************************ Edit lead section *****************************
//From http://en.wikipedia.org/w/index.php?title=User:ABCD/monobook.js&oldid=19452182
function addEditSection0(){
ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-edit');
if(!x) return;
var y = document.createElement('LI');
y.id = 'ca-edit-0';
if(x.className == 'selected'){
if(/&action=edit§ion=0$/.test(window.location.href)){
x.className = 'istalk';
y.className = 'selected';
} else {
x.className = 'selected istalk';
}
} else if(x.className == 'selected istalk'){
if(/&action=edit§ion=0$/.test(window.location.href)){
x.className = 'istalk';
y.className = 'selected istalk';
} else {
y.className = 'istalk';
}
} else {
y.className = x.className;
x.className = 'istalk';
}
var z = document.createElement('A');
if(x.children){
z.href = x.children[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
}else{
z.href = x.childNodes[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
}
}
//************************************ Regexp replace tab ************************************
//From http://en.wikipedia.org/w/index.php?title=User:Trilobite/Tools&oldid=17855224
//Renamed by JesseW.
function regexpReplaceTab() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("Editing ") == 0) addlilink(tabs, 'javascript:replace()', 'replace', '');
}
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);
}
}
//************************************ Tabs at bottom ************************************
function tabsAtBottom() {
var tabs = document.getElementById('p-cactions').cloneNode(true);
tabs.id = 'mytabs';
var listitems = tabs.getElementsByTagName('LI');
for (var i=0;i<listitems.length;i++) {
if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
}
document.getElementById('column-content').appendChild(tabs);
}
//************************************ Utility functions ************************************
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.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
function addlilink2(tabs, url, name, id, title) {
var l=addlilink(tabs,url,name,id);
l.lastChild.title=title;
return l;
}
/**** Add tab as menu ****/
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;
}
// ******* Cross browser textcontent
function textContent(el) {
if (el.textContent)
return el.textContent;
return el.innerText;
}
/************ add unwatch to watchlist ***********/
$(function () {
if (window.location.href.indexOf("Special:Watchlist") == -1) return;
var links = document.getElementById('content').getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
if (links[i].href.substring(links[i].href.length-15) != '&action=history')
continue;
var unwatch = document.createElement('a');
unwatch.href = "/w/index.php?title=Special:Watchlist&action=submit&remove=1&id[]="+encodeURIComponent(links[i].title);
unwatch.title = "Unwatch "+links[i].title;
unwatch.appendChild(document.createTextNode("unwatch"));
links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);
links[i].parentNode.insertBefore(links[i].previousSibling.cloneNode(true), unwatch);
}
});
/*
function talkpageplus()
{
var talkpagelink = document.getElementById('ca-talk');
if (talkpagelink.className == 'new')
{
talkpagelink.firstChild.href += '§ion=new';
}
}
$(talkpageplus);
*/
//*****************************************************************************************
window.onload = Main;
function Main()
{
// autoWikiWatchlist();
if (LivePreviewInstall) LivePreviewInstall();
addForceSummary()
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
// addlimenu(tabs, 'Watchlists', 'watchlists-menu');
// addWikiWatchlist("Interests");
// addWikiWatchlist("Wikipedia");
// addWikiWatchlist("Conversations");
// addWikiWatchlist("News");
addlilink2(tabs, "javascript:doLastDiff()", 'last', '',"Show most recent diff");
// addlilink2(tabs, "javascript:doPUI()", 'PUI', '', "Tag images as unverifiedimage");
addSinceTab(); /*Complicated if statements; need to find a neat way to do this...*/
// doNextItem();
regexpReplaceTab();
addEditSection0();
addPurgeTab();
// tabsAtBottom();
//automate();
//cesarb_fixDiffOverflowLoadListener();
}
//</pre>