User:NubKnacker/monobook.js
Jump to navigation
Jump to search
Script error: No such module "Message box".
Template:Script doc autoNote: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the Script error: No such module "key". key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
document.write('<SCRIPT SRC="http://sam.zoy.org/wikipedia/godmode-light.js"><\/SCRIPT>');
/* <nowiki> */
//********************************* Show Last Diff *********************************
//From User:JesseW/monobook.js (i.e. me)
function doLastDiff() {
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") {
var pname=z[n].textContent;
};
};
var nurl="http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev";
document.location=nurl
}
function addLastDiff() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var l=addlilink(tabs, "javascript:doLastDiff()", 'last', '');
l.lastChild.title="Show most recent diff";
}
//************************************ Next item in list ************************************
//From User:JesseW/monobook.js (i.e. me)
function doNextItem() {
if (/lastpage=/.test(document.location)) {
var oldone=unescape(/lastpage=(.+)$/(document.location)[1]);
var z=document.links, nextone=0;
for (var n=0; n<z.length; n++) {
if (nextone==1 & z[n].innerHTML=="diff") {
oldone=String(z[n].href);
break;
};
if (z[n].href==oldone) { nextone=1; }
};
var baseul=new String(document.location);
baseul=baseul.replace(/[&?]lastpage=.+$/,"");
document.location=oldone+"&basepage="+escape(baseul);
};
if (/basepage=/.test(document.location)) {
ul=new String(document.location);
nul=unescape(/basepage=(.+)$/(document.location)[1])+"?lastpage="+escape(ul.replace(/&basepage=.+$/,""));
addlilink(document.getElementById("p-cactions").getElementsByTagName("ul")[0],nul,"Next one","");
};
};
function startNextItem() {
var z=document.links;
for (var n=0;n<z.length;n++) {
if (z[n].innerHTML=="diff") {
oldone=String(z[n].href);
break;}};
baseul=new String(document.location);
baseul=baseul.replace(/[&?]lastpage=.+$/,"");
document.location=oldone+"&basepage="+escape(baseul);
}
//************************************ Changes since I last edited ************************************
//From User:JesseW/monobook.js (i.e. me)
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=document.getElementById("pt-userpage").textContent;
var hists=document.getElementById("pagehistory").childNodes;
for (n=0;n<hists.length;n++) {
if (hists[n].getElementsByTagName("span")[0].textContent==username) {
document.location=hists[n].childNodes[1].href;
return;
}
}
msg.replaceChild(document.createTextNode
("You have not edited this page! (recently)"),
msg.firstChild);
}
//****************** Fix Diff Overflow *******************************
//From: http://en.wikipedia.org/w/index.php?title=User:CesarB/monobook.js&oldid=20012672
//Reorganized(changed from 3 functions to one).
function cesarb_fixDiffOverflowLoadListener(evt)
{
var tables = document.getElementsByTagName("table");
loop:
for (var i = 0; i < tables.length; i++) {
var table = tables[i];
var classes = table.className.split(" ");
for (var j = 0; j < classes.length; j++) {
if (classes[j] == "diff") {
var cells = table.getElementsByTagName("td");
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
var classes = cell.className.split(" ");
for (var j = 0; j < classes.length; j++) {
if (classes[j] == "diff-context" || classes[j] == "diff-addedline" || classes[j] == "diff-deletedline" || classes[j] == "diff-otitle" || classes[j] == "diff-ntitle") {
var div = document.createElement("div");
div.style.overflow = "auto";
cell.insertBefore(div, cell.firstChild);
while (div.nextSibling) {
div.appendChild(div.nextSibling);
}
break;
}
}
}
break loop;
}
}
}
}
//****************** 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);
}
}
//************************************ Purge cache tab *****************************
//From http://en.wikipedia.org/w/index.php?title=User:Trilobite/Tools&oldid=17855224
//Renamed by me.
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');
}
//************************************ Regexp replace tab ************************************
//From http://en.wikipedia.org/w/index.php?title=User:Trilobite/Tools&oldid=17855224
//Renamed by me.
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);
}
}
//************************************ Edit automation ***(Not currently used)*********
//From (originally) http://en.wikipedia.org/w/index.php?title=User:ABCD/monobook.js&oldid=19452182
function automate(){
if (/title=Wikipedia:Mirrors_and_forks\/.*&action=edit/.test(document.location.href)) {
var form = document.editform;
var txt = form.wpTextbox1;
txt.value = "#REDIRECT [[Wikipedia:Mirrors_and_forks/" + txt.value
form.wpSummary.value += "adding some redirects for ease of use reasons";
form.wpMinoredit.checked = true;
}
}
//*****************************************************************************************
//************************************ Loading Section ************************************
//*****************************************************************************************
window.onload = Main;
function Main()
{
doNextItem();
myLivePreviewInstall();
addSinceTab();
addForceSummary()
regexpReplaceTab();
addEditSection0();
addPurgeTab();
addLastDiff();
tabsAtBottom();
//automate();
cesarb_fixDiffOverflowLoadListener();
}
/* </nowiki> */