User:Sceptre/monobook.js

// mw.loader.load(             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); document.write(' '); $(tblinks);

function tblinks { mw.util.addPortletLink('p-tb', 'http://en.wikiquote.org/wiki/Wikiquote:Community_Portal', 'Community Portal'); var tabs = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlimenu(tabs, 'Monobooks', 'mb'); mw.util.addPortletLink('mb', '/wiki/User:Sceptre/monobook.js', 'monobook.js'); mw.util.addPortletLink('mb', '/wiki/User:Sceptre/monobook.css', 'monobook.css'); if(document.title.indexOf("Editing User talk:") == 0) {       mw.util.addPortletLink('p-tb', 'javascript:warn', 'Warn'); } if (document.title.indexOf("Editing") == 0) {     addlimenu(tabs, 'Editing prompts', 'tags'); mw.util.addPortletLink('p-cactions', 'javascript:film', 'film', 'ca-film', 'Categorize', 'f', 'ca-history'); mw.util.addPortletLink('tags', 'javascript:tag(prompt("Template name?"))', 'Tag') mw.util.addPortletLink('tags', 'javascript:delbec', 'Speedy') } }

function addlimenu(tabs, name, id) {   (na = document.createElement("a")).appendChild(document.createTextNode(name)); na.href = "#"; var mn = document.createElement("ul"); (li = document.createElement("li")).appendChild(na); li.appendChild(mn); if(id) li.id = id; li.className = 'tabmenu'; tabs.appendChild(li); return mn; // useful because it gives us the  to add s to }

function warn {   var txt = document.editform.wpTextbox1; var type = prompt("Which standard warning do you wish to issue?", "test"); var severity = prompt("How severe is the violation?", "1"); var msgtext = " ~"; if (severity != "") { var summary = "Your recent edits to Wikiquote"; } else { var summary = prompt("What is the summary?"); }   document.editform.wpSummary.value = summary; document.editform.wpMinoredit.checked = true; if(txt.value.length > 0) txt.value += '\n'; txt.value += msgtext; document.editform.submit; }

function tag(message) {   var auto=confirm("Auto-save?"); var txt = document.editform.wpTextbox1; summary = "Add "; var message = "\n"; txt.value = message + txt.value; txt = document.editform.wpSummary; if (txt.value!="") { summary=txt.value+"; "+summary; } txt.value = summary; if (auto==true) { document.editform.submit; } }

function delbec {   var txt = document.editform.wpTextbox1; var type = prompt("Which criteria?"); var msgtext = "\n"; var summary = "Speedy delete: " + type + ""; document.editform.wpSummary.value = summary; if(txt.value.length > 0) txt.value += '\n'; txt.value = msgtext + txt.value; document.editform.submit; }

function wpTextboxReplace {   var s = prompt("Search regexp:"); if(s){ var r = prompt("Replace /"+s+"/ with:"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "mg"), r); } } $(function {    if (document.forms.editform) {        mw.util.addPortletLink('p-cactions', 'javascript:wpTextboxReplace', 'replace', 'ca-replace', 'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));   } });

function film {   var txtbox = document.editform.wpTextbox1; var country = prompt("Which country?"); var summary = "Categorize film by country"; txtbox.value=txtbox.value+""; document.editform.wpSummary.value = summary; document.editform.submit; }

// var transwiki_log_location = "Wikibooks:Transwiki log"; function add_link(url, name) { //replace_editing_help(url, name);    // remove the "//" at the start of this line to replace the "editing help" under the edit window with the links //before_editbox(url, name);         // remove the "//" at the start of this line to place the links before the editing box //the following options are skin-specific. //monobook_tab(url, name);           // remove the "//" at the start of this line to place the links in tabs in the monobook skin monobook_toolbox(url, name);       // remove the "//" at the start of this line to place the links in the toolbox in the monobook skin //classic_header(url, name);         // remove the "//" at the start of this line to place the links in the header in the classic skin //classic_quickbar(url, name);       // remove the "//" at the start of this line to place the links in the quickbar in the classic skin //nostalgia_header(url, name);       // remove the "//" at the start of this line to place the links in the header in the nostalgia skin //cologneblue_quickbar(url, name);   // remove the "//" at the start of this line to place the links in the quickbar in the cologne blue skin } function before_editbox(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var form = document.editform; var x; for (x = form.firstChild; x; x = x.nextSibling) if (x.tagName == 'BR') {       form.insertBefore(document.createTextNode(' | '), x); form.insertBefore(na, x); break; }   else if (x.tagName == 'TEXTAREA') {       form.insertBefore(na, x); form.insertBefore(document.createElement('br'), x); break; } } function replace_editing_help(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var form = document.editform; var em = form.getElementsByTagName('em'); if (em.length > 1) form.replaceChild(na, em[1]);      // we haven't yet removed the "editing help" link, so replace it  else {     // either there's a br and a list of templates, or the editpage-copywarn div var x;     for (x = em[0]; x && x.tagName != "BR" && x.tagName != "DIV"; x = x.nextSibling); if (!x) { // didn't find anything! so just append form.appendChild(document.createTextNode(' | ')); form.appendChild(na); }     else {         form.insertBefore(document.createTextNode(' | '), x); form.insertBefore(na, x); }   } } function monobook_tab(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); document.getElementById('p-cactions').getElementsByTagName('ul')[0].appendChild(li); } function monobook_toolbox(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); document.getElementById('p-tb').getElementsByTagName('ul')[0].appendChild(li); } function classic_header(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var td = document.getElementById('topbar').getElementsByTagName('table')[0].getElementsByTagName('td')[1].getElementsByTagName('p')[0]; if (td.hasChildNodes) td.appendChild(document.createTextNode(' | ')); td.appendChild(na); } function classic_quickbar(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); document.getElementById('quickbar').appendChild(na); } function nostalgia_header(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var bar = document.getElementById('topbar'); var br = bar.getElementsByTagName('br')[1]; bar.insertBefore(document.createTextNode(' | '), br); bar.insertBefore(na, br); } function cologneblue_quickbar(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var qb = document.getElementById("quickbar"); qb.appendChild(na); qb.appendChild(document.createElement('br')); } function sig { return ' ' + ''; } // End of generic code function transwiki_history { var txt = document.editform.wpTextbox1; // Replace double braces, add a newline at end txt.value = txt.value.replace(/{/g, "&#123;") + "\n"; txt.value = txt.value.replace(/}/g, "&#125;"); // Find minor edits, and make them regexp-friendly txt.value = txt.value.replace(/ m \(/g, " (MINOR"); txt.value = txt.value.replace(/ m$/gm, " (MINOR)"); // Find edits without summaries, and make them regexp-friendly txt.value = txt.value.replace(new RegExp("([^)])\\r", "gm"), "$1 \r"); // Replace the "(cur) (last)  " at the start of each line with "*" and link user names  txt.value = txt.value.replace(new RegExp("^\\(cur\\) \\(last\\)  ([0-9][0-9]:[0-9][0-9], [0-9][0-9]? [A-Z][a-z]* 200[0-9]) ([^(\\n\\r]*) (\\(.*\\))$", "gm"), "*$1 $2 $3"); // Fix minor edits txt.value = txt.value.replace(/ \(MINOR/g, " m ("); // Fix edits without summaries txt.value = txt.value.replace(/ \(\)$/gm, ""); txt.value = txt.value.replace(new RegExp("^([^(\\n\\r]*) \\((.*)\\)$", "gm"), "$1 ($2)"); // Add header  var title;  if (!document.title.match(/Talk:Transwiki:(.*) - (Preview|Edit)/))    title = prompt("Couldn't find article name.");  else    title = RegExp.$1;  txt.value = "This article was transwikied from " + title + "." + sig + "\n\nThe history of the article there was:\n" + txt.value;  // And summary  document.editform.wpSummary.value = "transwikied from " + title + ""; } function transwiki_summary {  var txt = document.editform.wpTextbox1;  var title;  if (!document.title.match(/Editing Transwiki:(.*) - (Preview|Edit)/))    title = prompt("Couldn't find article name.");  else    title = RegExp.$1;  document.editform.wpSummary.value = "transwikied from " + title + ""; } function transwiki_log(title) {  var txt = document.editform.wpTextbox1; txt.value += "*" + title + " &rarr; Transwiki:" + title + "" + sig; document.editform.wpSummary.value = "Transwiki:" + title + " transwikied from " + title + ""; } function onload_transwiki { if (document.title.indexOf("Editing ") == 0) {     if (document.title.indexOf("Editing Talk:Transwiki:") == 0) add_link('javascript:transwiki_history', 'Wikify History'); else if (document.title.indexOf("Editing Transwiki:") == 0) add_link('javascript:transwiki_summary', 'Transwiki summary'); else if (document.title.indexOf("Editing " + transwiki_log_location) == 0) add_link('javascript:transwiki_log(prompt("Title?"))', 'Log entry'); } //add_link("/wiki/" + transwiki_log_location, 'Transwiki log');       // remove the "//" from the start of this line to add a link to the transwiki log. You may want to use a specific add_link function instead, e.g. monobook_toolbox, so it doesn't appear in the same place as the editting links. } $(onload_transwiki); //