User:Xenophon (bot)/monobook.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
The accompanying .css page for this skin is at User:Xenophon (bot)/monobook.css. |
/* <pre><nowiki> */
/**
* [[User:Bookofjude]]'s monobook.js, based on primarily on [[User:Wayward]]'s,
* which in turn is based on [[User:Alphax/monobook.js]]'s
* with many of [[User:Wayward]]'s own mods
* Must use [[User:Wayward/monobook.css]] for full tab functionality
* Forked from [[User:ABCD/monobook.js]] around April 2005
* Dual licensed under the GFDL and GPL
* See also: [[User:JesseW/monobook.js]]
* And best of all: [[WP:US]]
**/
$(function (){
if(document.forms.editform) {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, 'javascript:softRedirect();', 'Soft redirect', 'ca-redirect');
}
});
$(function (){
if(queryString("submitmove")=="true") document.forms[0].wpMove.click()
if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click();
if((document.title.indexOf("Move page -") == 0)&&(!document.forms[0].wpMove)) window.close()
});
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
};
function softRedirect(){
var txt = document.editform.wpTextbox1;
var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?(\\[\\[[^\\]]*\\]\\])[\\S\\s]*|[\\s\\S]*", "g"), "$1");
if (r==""){
var r = "[["+prompt('What page should the redirect point to?')+"]]";
}
txt.value = "{{subst:Dated soft redirect|"+r+"}}";
var summary = document.editform.wpSummary;
summary.value = "Converted to soft redirect";
}
/*** Add generic tab ***/
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
/*** [[User:Lightdarkness]]'s include function ***/
function inc (file) {
var lt = String.fromCharCode(60);
var gt = String.fromCharCode(62);
document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}
/*** Includes ***/
inc("User:Bookofjude/godmode.js");
inc("User:Bookofjude/autoedit.js");
/*** Popups customisations, see [[Wikipedia:Tools/Navigation popups]] ***/
popupFixRedirs = true;
popupRedirAutoClick = 'wpPreview';
popupFixDabs = true;
popupStructure = 'menus';
/*** Hooks ***/
$(AddTime);
$(addPurge);
$(akeytt);
$(addGoogle);
$(setEditForm);
$(function () {
if(document.forms.editform) {
addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history');
addLink('p-cactions', 'javascript:changeSummary()', 'summary', 'ca-summary', 'Change the summary of the page and save', '', 'ca-replace');
}
});
$(changekeys);
function getPname(){
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") return z[n].textContent;
};
}
function changeSummary(){
// replace2("--", "—");
document.editform.wpSummary.value = "cleaned up the header - [[User:Bookofjude/header cleanup|header cleanup info]]";
document.editform.submit();
}
/*** GENERIC FUNCTIONS ***/
/**** Tabs and functions ****/
// Add test-n templates to user talk pages
function testn(number)
{
var page = prompt("Vandalism to which article?")
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + number + "-n|" + page + "}} ~~~~";
f.wpSummary.value = "Your edits to [[" + page + "]]"
document.editform.wpWatchthis.checked = false;
}
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
};
function setEditForm() {
var setSubmit = queryString('setsubmit');
if (setSubmit) {
var move = document.getElementById('movepage');
move.submit();
}
}
// Add duration for s/block by
function duration(number)
{
var duration = prompt("Block duration")
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{s/block2|signature=~~~~|time=" + duration + "}}";
f.wpSummary.value = "You have been blocked for " + duration + ""
document.editform.wpWatchthis.checked = false;
}
// appends msg to the currently editted page, sets the summary to summ,
// and marks or unmarks the "Watch this page" checkbox according to watch
function edit_summary_watch(msg, summ, watch)
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += msg;
f.wpSummary.value = summ;
f.wpWatchthis.checked = watch;
}
// Places perm block and name block tags at top of edit section,
// and marks or unmarks the "Watch this page" checkbox according to watch
function perm_name_block(msg, summ, watch)
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
var temp = t.value;
t.value = msg;
t.value += '\n\n';
t.value += temp;
f.wpSummary.value = summ;
f.wpWatchthis.checked = watch;
}
/*** Add generic tab ***/
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
/*** Gets a page name ***/
function getPname() {
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") return z[n].textContent;
};
}
/*** Gets a username on userpages ***/
function getUname() {
return document.URL.match(/:.*:(.*)/)[1];
}
/*** Adds something to the contentSub ***/
function addcsub(name, link)
{
var csub = document.getElementById('contentSub');
var csuba = document.createElement('a');
csuba.href = link;
csuba.appendChild(document.createTextNode(name));
csub.appendChild(csuba);
return csuba;
}
function addLink(where, url, name, id, title, key, after){
//* where is the id of the toolbar where the button should be added;
// i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
//
//* url is the URL which will be called when the button is clicked.
// javascript: urls can be used to do more complex things.
//
//* name is what will appear as the name of the button.
//
//* id is the id of the button; it's best to define one.
// Use a prefix to make sure its unique. Optional.
//
//* title is the tooltip title that gives a longer description
// of the button; if you define a accesskey, mention it here. Optional.
//
//* key is the char you want for the accesskey. Optional.
//
//* after is the id of the button you want to follow this one. Optional.
//
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
if(after) {
tabs.insertBefore(li,document.getElementById(after));
} else {
tabs.appendChild(li);
}
if(id) {
if(key && title) { ta[id] = [key, title]; }
else if(key) { ta[id] = [key, '']; }
else if(title) { ta[id] = ['', title];}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
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 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;
}
/*** Add tab wrapper for addlilink ***/
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
// global scope
function replace2(s, r) {
if(s) {
if(!r && r != '') return;
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
}
function replWS(){
replace2('(\\n)', '$1$1');
}
function moonlitReplace(){
replace2(prompt("Regexp?"), '{{EBDheader|previous=$1|next=$2|wikipedia=$3}}');
}
function unlitReplace(){
replace2("{{EBD1897 entry\\|([^|]*)\\|([^|]*)\\|([^}]*)}}", "{{EBDheader|previous=$1|next=$2|wikipedia=$3}}");
}
function moonlitReplace2(){
replace2("<div[\\s\\S\\n\\R]*\\[\\[EBD1897:([^|]*)"
+ "\\|[^\\]]*\\]\\][\\s\\S\\n\\R]*\\[\\[EBD1897:([^|]*)"
+ "\\|[^\\]]*\\]\\][\\s\\S\\n\\R]*\\[\\[w:([^|]*)\\|[^\\]]*"
+ "\\]\\][\\s\\S\\n\\R]*</div>", "{{EBDHeader|previous=$1|next=$2|wikipedia=$3}}");
}
function ebdReplace(){
replace2("\\[\\[EBD1897:", "[[../");
}
function ebdIndex(){
replace2("\\* \\[\\[Easton's Bible Dictionary \\(1897\\)/", "* [[../");
}
function pipeLinks(){
replace2("\\[\\[\\.\\./([^|\\]]*)\\]\\]", "[[../$1|$1]]");
}
function edHeader(){
replace2("<table.*>\\n<tr><td.*>([^\\r\\n]*)\\n<tr><td>Written by:<td>[\\s\\S\\r\\n]*"
+ "<tr><td>Poem #:<td>'''([0-9]+)'''\\n[^']*<tr><td>'''Preceded by:'''<td>"
+ "'''\\[\\[([^\\]]*)\\]\\] -([0-9]+)-'''\\n<tr><td>'''Succeeded by:'''<td>"
+ "'''\\[\\[([^\\]]*)\\]\\] -([0-9]+)-'''\\n[\\s\\S\\r\\n]*\\["
+ "\\[w:([^\\|]*)\\|Wikipedia article\\]\\]\\n</table>", "{{EDheader|title=$1|number=$2|prevt=$3|prevn=$4|nextt=$5|nextn=$6|wikipedia=$7}}");
}
function moveCategory(){
replace2("^(\\[\\[[Cc]ategory:[^\\]]*\\]\\](?:\\n)?"
+ "\\[\\[[Cc]ategory:[^\\]]*\\]\\](?:\\n)?)([\\S\\s\\r\\n]*)", "$2$1");
}
function cleanDickinson(){
replace2("<br />\\n<br />", "");
replace2("\\n\\n\\n", "");
replace2("<br />(\\n)({{Emily)", "$1$1$2");
}
function convertTable(){
replace2("<table>", "{|");
replace2("<tr>", "|-");
replace2("<tr([^>]*)>", "|- $1");
replace2("<td>", "|");
replace2("<td([^>]*)>", "|$1|");
replace2("</table>", "|}");
replace2("</t[rd]>", "");
}
function removeBreaks(){
replace2("<br( /)?>", "");
}
function removeBreaks2(){
replace2("(\\n)<br />(\\n)", "$1$2");
}
function removeBreaks3(){
replace2("([\\s\\S]*)(\\n)([\\s\\S]*)(<br( /)?>)({{Emily)", "$1$2$3$4$2$2$6");
}
function setupReplacements() {
if(document.forms.editform) {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'replace', 'replf');
var replf = document.getElementById('replf').getElementsByTagName('ul')[0];
// addlilink(replf, 'javascript:replWS()', 'Double whitespace', '');
// addlilink(replf, 'javascript:moonlitReplace()', 'EBD subst Header', '');
// addlilink(replf, 'javascript:moonlitReplace2()', 'EBD subst Header 2', '');
// addlilink(replf, 'javascript:unlitReplace()', 'EBD unsubst Header', '');
// addlilink(replf, 'javascript:ebdReplace()', 'EBD interlinks', '');
// addlilink(replf, 'javascript:ebdIndex()', 'EBD index to relative', '');
// addlilink(replf, 'javascript:pipeLinks()', 'Pipe relative links', '');
addlilink(replf, 'javascript:convertTable()', 'Convert to Wikitable');
addlilink(replf, 'javascript:edHeader()', 'Emily Dickinson header', '');
addlilink(replf, 'javascript:removeBreaks2()', 'Remove line breaks 1');
addlilink(replf, 'javascript:cleanDickinson()', 'Clean line breaks', '');
addlilink(replf, 'javascript:moveCategory()', 'Move categories', '');
addlilink(replf, 'javascript:removeBreaks3()', 'Remove line breaks 2');
// addlilink(replf, 'javascript:removeBreaks()', 'Remove line breaks');
addlilink(replf, 'javascript:changeSummary()', 'Summary');
} else {
var x = document.getElementById('ca-next')
if (x) {
g = x.getElementsByTagName('a')[0];
y = g.href.replace("/wiki/", "/w/index.php?action=edit&title=");
g.href = y;
}
}
}
$(setupReplacements);
function changekeys() {
ta['ca-replace'] = ['r', 'Find and replace'];
ta['ca-summary'] = ['k', 'Auto-edit summary and save'];
ta['replf'] = ['q', 'Find and replace drop down'];
ta['ca-next'] = ['g', 'Go to the next page'];
ta['ca-previous'] = ['b', 'Go to the previous page'];
akeytt();
}
/*** Add purge tab ***/
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];
var pf = document.createElement('form');
pf.action = '?action=purge';
pf.method = 'POST';
pf.id = 'pf';
x.appendChild(pf);
addlilink(tabs, 'javascript:document.getElementById("pf").submit();', 'purge', 'ca-purge');
}
/*** Add google tab ***/
function addGoogle()
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, 'http://www.google.com.au/search?q=' + getPname(), 'google', 'ca-google', 'ca-google');
}
/*** Adds a link for the clock ***/
function AddTime() {
var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0];
addlilink(toplinks, 'http://192.168.0.64/rc.php', 'Recent changes', '');
addlilink(toplinks, '#', '', 'utcdate');
showtime();
}
/*** Auto-updating clock ***/
function showtime() {
var timerID;
var now = new Date();
var timeValue = now.toLocaleString().replace(/GMT/, "UTC");
var timeValue2 = now.toUTCString().replace(/GMT/, "UTC");
document.getElementById('utcdate').firstChild.innerHTML = timeValue + "<br>" + timeValue2;
timerID = setTimeout('showtime()', 100);
}
function morelinks() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("User") == 0) {
addlilink(tabs, '/wiki/Special:Contributions/' + getUname(), 'contributions', 'ca-contribs');
addlilink(tabs, 'http://192.168.0.64/rc.php?whitelist=' + getUname(), 'whitelist', 'ca-whitelist');
addlilink(tabs, 'http://192.168.0.64/rc.php?blacklist=' + getUname(), 'blacklist', 'ca-blacklist');
}
}
/* </nowiki></pre> */