User:Konstable/monobook.js

<!-- // detect browser - disable everything for IE, so VandalProof doesn't complain so mcuh

var detect = navigator.userAgent.toLowerCase; var IE; var place = detect.indexOf('msie') + 1;

if (place) IE=true;

if (!IE) {

// Script from User:Lupin/recent2.js /* mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'             + '&action=raw&ctype=text/javascript&dontcountme=s');

// User:Lupin/popups.js

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

popupStructure = 'original';*/

// Install InstaView /*mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Pilaf/instaview.js&action=raw&ctype=text/javascript');

InstaView.conf.user.name = 'Konstable';*/

// This is to keep track of who is using InstaView: User:Pilaf/instaview.js

// This will add an [edit top] link at the top of all pages except preview pages // by User:Pile0nades

// Add an [edit top] link to pages addOnloadHook(function {  // if this is preview page or generated page, stop  if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/Special:") != -1) return;

// get the page title var pageTitle = document.title.split(" - ")[0].replace(" ", "_");

// create div and set innerHTML to link var divContainer = document.createElement("div"); divContainer.innerHTML = ' [edit top] ';

// insert divContainer into the DOM before the h1 if(window.location.href.indexOf("&action=edit") == -1) document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);

if(window.location.href.indexOf("&action=edit&section=0") != -1) document.getElementById("wpSummary").value = "/* Intro */ "; });

function addlilink(tabs, url, name, id, title, key){ 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); 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 tnaddlilink(url, name) { var na = document.createElement('a'); na.setAttribute('href', url);

var txt = document.createTextNode(name); na.appendChild(txt);

var li = document.createElement('li'); li.appendChild(na); return li; }

/* */ /* quickimgdelete.js * Current version: 1.10.2 * ======================================= * Created by Howard Cheng * Released under the GNU Public License (GPL) * Full documentation at User talk:Howcheng/quickimgdelete.js * ======================================= */ // ==General configuration== qid_autosave = true; // Should the edits be saved automatically? // Site info qid_path = "/w/index.php"; qid_prettypath = "/wiki/"; qid_hostname = window.location.hostname;

// ==Helper functions== // from User:Jnothman/automod.js function GuessUTCDate { var monthnames = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var today = new Date; return today.getUTCFullYear + ' ' + monthnames[today.getUTCMonth] + ' ' + today.getUTCDate; }

// From en:User:Lupin/autoedit.js function getParamValue(paramName) { var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var h=document.location; var m=cmdRe.exec(h); if (m) { try { return decodeURIComponent(m[1]); } catch (someError) {} } return null; }

function qid_openWindow(url, windowName) { if (!windowName) windowName = 'qid_window'; var res = window.open(url, windowName); if (!res) alert("qid_openWindow: window.open returned null"); }

function qid_getFileHistory { var el = document.getElementById('filehistory') if (!el) { alert("qid_getFileHistory: Cannot find filehistory ... exiting"); return null; } while (el.nextSibling) { el = el.nextSibling; if (el.tagName && el.tagName.toLowerCase == 'ul') break; } if (!el) { alert("qid_getFileHistory: Cannot find UL tag ... exiting"); return null; } var els = el.getElementsByTagName('li'); if (!els) { alert("qid_getFileHistory: Cannot find LI tag ... exiting"); return null; } return els; }

function qid_getUploader { // Get uploader from first point in the list under "File history" // Uploader is stored in second A tag in UL tag under "File history" // Returns title of user page (without name space) in URL form var els = qid_getFileHistory; var uploaders = new Array; var re1 = new RegExp('http://' + (qid_hostname + qid_prettypath).replace(/\./g, '\\.') + 'User:(.*)$'); var re2 = new RegExp('http://' + (qid_hostname + qid_path).replace(/\./g, '\\.') + '\\?title=User:([^&]*)'); var re3 = /User( talk)?:(.*)$/; // this is for IE and handling Unicode characters

var m; var uploader; var uploaderList = ""; var count = 0; var el = els[0]; do { var as = el.childNodes; for (var k=0; k 0) uploaderList += "; "; uploaderList += count + " - " + uploader; uploaders[uploaders.length] = uploader; count += 1; }   el = el.nextSibling; } while (el);

if (!uploaders || uploaders.length == 0) { alert("qid_getUploader: Cannot find uploader ... exiting"); return null; } if (uploaders.length == 1) return uploaders[0];

var which = parseInt(window.prompt("Choose which uploader to notify: " + uploaderList, "")); if (isNaN(which) || which < 0 || which >= uploaders.length) { alert("qid_getUploader: Invalid selection ... exiting"); return null; } return uploaders[which]; }

function qid_getUploadDate { var els = qid_getFileHistory; var re = /\d{2}:\d{2}, \d+ [a-z]+ \d{4}/i; var m; var dt; var el = els[0]; var as = el.childNodes; for (var k=0; k -1) { var lastbracepos = editformval.indexOf('}}', templatepos) + 1; editformval = editformval.substr(0, templatepos) + editformval.substr(lastbracepos + 2); } return editformval; }

function qid_doesTemplateExist(editformval, template) { var templatepos = editformval.indexOf('{{' + template); return (templatepos > -1); }

function qid_checkForRedirect(editformval, type) { if (editformval.toLowerCase.indexOf("#redirect") == -1) return;

var re = /\[\[([^\]]+)\]\]/; var m = re.exec(editformval); var redirtarget = m[1]; var fakeaction = getParamValue("fakeaction"); var pagename = getParamValue("target"); var redirurl = qid_path + '?title=' + redirtarget + '&action=edit&fakeaction=' + fakeaction + '&target=' + pagename; if (type) redirurl += '&type=' + type; window.location.replace(redirurl); }

function qid_saveEditForm(txt, summary) { document.editform.wpTextbox1.value = txt; document.editform.wpSummary.value = summary; if (qid_autosave) document.editform.wpSave.click; }

function qid_userBeenWarned(txt, template) { var re = eval("/\/;"); return re.test(txt); }

function qid_removeNamespace(fullpagename) { var colonPos = fullpagename.indexOf(':'); var pagename = fullpagename.substring(colonPos + 1); return pagename; }

/** ================================================================================ * ==Automatic 'nominate for deletion/pui/imagevio' script== * The actions in this section do three things: * 1. Add a tag to the image page. * 2. List the image on a log page. * 3. Add a warning template to the uploader's talk page. */ // Configuration nfd_text = "Nominate for deletion"; nfd_tooltip = "Nominate this image for deletion"; nfd_prompt = "Why do you want to nominate this image for deletion?"; nfd_delReq = "Wikipedia:Images_and_media_for_deletion/" + GuessUTCDate.replace(' ', '_'); nfd_deleteTemplate = "ifd"; nfd_idwTemplate = "idw"; nfd_ifdTemplate = "ifd2"; nfd_glossary = new Array( new Array("AB", "Absent uploader"),  new Array("AU", "Absent uploader"),  new Array("CV", "Copyright violation"),  new Array("OB", "Obsolete"),  new Array("OR", "Orphaned"),  new Array("LQ", "Low quality"),  new Array("UE", "Unencyclopedic") );

pui_text = "Possibly unfree image"; pui_tooltip = "Mark this image as possibly unfree"; pui_prompt = "Why do you think this image is possibly unfree?"; pui_delReq = "Wikipedia:Possibly_unfree_images/" + GuessUTCDate.replace(' ', '_'); pui_deleteTemplate = "PUIdisputed"; pui_idwTemplate = "idw-pui"; pui_ifdTemplate = "pui2";

vio_text = "Copyright violation"; vio_tooltip = "Mark this image as a copyright violation"; vio_prompt = "Enter the URL that this image is copied from."; vio_delReq = "Wikipedia:Copyright_problems/" + GuessUTCDate.replace(' ', '_') + "/Images"; vio_deleteTemplate = "imagevio"; vio_idwTemplate = "idw-cp";

function nfd_tagImage(which) { var promptTxt; var targetUrl; var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; editlk += '&fakeaction=' + which + '_delete'

switch (which) { case 'nfd': promptTxt = nfd_prompt; targetUrl = nfd_delReq; break; case 'pui': promptTxt = pui_prompt; targetUrl = pui_delReq; break; case 'vio': promptTxt = vio_prompt; targetUrl = vio_delReq; editlk += '&url=' + reason; break; }

var reason = prompt(promptTxt, ''); if (!reason) return;

var pagename = encodeURIComponent(mw.config.get('wgPageName')); var uploader = qid_getUploader; if (!uploader) return; qid_openWindow(qid_path + '?title=User_talk:' + uploader                + '&action=edit&fakeaction=' + which + '_warn&target=' + pagename); qid_openWindow(qid_path + '?title=' + targetUrl + '&action=edit&fakeaction=' + which + '_add'                 + '&target=' + pagename + '&reason=' + encodeURIComponent(reason)                 + '&uploader=' + uploader, 'qid_ifd_window'); window.location = editlk; }

function nfd_addDeleteTemplate(template, otherparam) { var txt = ''; var editformval = qid_removeTemplate(document.editform.wpTextbox1.value, 'untagged'); qid_saveEditForm(txt + '\n' + editformval, summary); }

function nfd_addIdwTemplate(template, target) { var editformval = document.editform.wpTextbox1.value; qid_checkForRedirect(editformval); var txt =  + target + ; editformval += '\n' + txt + '\n'; qid_saveEditForm(editformval, txt); }

function nfd_updateDelReq(target, reason, uploader) { var imageName = qid_removeNamespace(target); var abbrevCount = 0; for (var i = 0; i < nfd_glossary.length; i++) { var abbrev = nfd_glossary[i][0]; var meaning = nfd_glossary[i][1]; var re = eval("/\\b" + abbrev + "\\b/"); if (re.test(reason)) reason = reason.replace(re, meaning); } var txt = '' + imageName + ''; var editformval = document.editform.wpTextbox1.value + '\n' + txt + ' ' + ' \n'; var summary = 'Nominating ' + target + ''; qid_saveEditForm(editformval, summary); }

function pui_updateDelReq(target, reason) { var imageName = qid_removeNamespace(target); var txt = ''; var editformval = document.editform.wpTextbox1.value + txt + ' ' + ' \n'; var summary = document.editform.wpSummary.value + 'Adding ' + target + ''; qid_saveEditForm(editformval, summary); }

function vio_updateDelReq(target, url) { var txt = '* ' + target + ' from [' + url + '].'; var editformval = document.editform.wpTextbox1.value + txt + ' ' + ' \n'; var summary = document.editform.wpSummary.value + 'Adding ' + target + ''; qid_saveEditForm(editformval, summary); }

function nfd_onload { if (document.getElementById('ca-edit') == null) // not editable by non-admin return; if (wgAction == "view" && wgCanonicalNamespace == "Image") { mw.util.addPortletLink('p-tb', 'javascript:nfd_tagImage(\'nfd\')', nfd_text, 'nom-for-del', nfd_tooltip); mw.util.addPortletLink('p-tb', 'javascript:nfd_tagImage(\'pui\')', pui_text, 'pui', pui_tooltip); mw.util.addPortletLink('p-tb', 'javascript:nfd_tagImage(\'vio\')', vio_text, 'imagevio', 'vio_tooltip'); } var fakeaction = getParamValue('fakeaction'); switch (fakeaction) { case 'nfd_delete': nfd_addDeleteTemplate(nfd_deleteTemplate); break; case 'pui_delete': nfd_addDeleteTemplate(pui_deleteTemplate); break; case 'vio_delete': nfd_addDeleteTemplate(vio_deleteTemplate,        decodeURIComponent(getParamValue('url'))); break; case 'nfd_warn': nfd_addIdwTemplate(nfd_idwTemplate, decodeURIComponent(getParamValue('target'))); break; case 'pui_warn': nfd_addIdwTemplate(pui_idwTemplate, decodeURIComponent(getParamValue('target'))); break; case 'vio_warn': nfd_addIdwTemplate(vio_idwTemplate, decodeURIComponent(getParamValue('target'))); break; case 'nfd_add': nfd_updateDelReq(decodeURIComponent(getParamValue('target')),        decodeURIComponent(getParamValue('reason')), decodeURIComponent(getParamValue('uploader'))); break; case 'pui_add': pui_updateDelReq(decodeURIComponent(getParamValue('target')),        decodeURIComponent(getParamValue('reason'))); break; case 'vio_add': vio_updateDelReq(decodeURIComponent(getParamValue('target')),        decodeURIComponent(getParamValue('reason'))); break; } }

addOnloadHook(nfd_onload);

/** ================================================================================ * ==Automatic 'mark no source' (mns) and 'mark no license' (mnl) script== // mnx = applies to all * The actions in this section do two things: * 1. Add a tag to the image page. * 2. Add a warning to the uploader's talk page. */ // Configuration mns_text = "No source"; mns_tooltip = "Mark this image as missing required source information";

mnl_text = "No license"; mnl_tooltip = "Mark this image as missing required licensing information";

mnsl_text = "No source/license"; mnsl_tooltip = "Mark this image as missing both required source and licensing information";

mnr_text = "No rationale"; mnr_tooltip = "Mark this image as missing fair use rationale";

mor_text = "Orphaned fair use"; mor_tooltip = "Mark this image as an orphaned fair use image";

mrfu_text = "Replaceable fair use"; mrfu_tooltip = "Mark this image as a replaceable fair use image";

mfud_text = "Fair use disputed"; mfud_tooltip = "Mark this image as fair use disputed";

mbsr_text = "Base URL"; mbsr_tooltip = "This image links directly to the image or is a generic base URL";

function mnx_markNo(action) { var pagename = encodeURIComponent(mw.config.get('wgPageName')); var txt; var warnaction = action; switch (action) { case "mnx_mns": case "mnx_mnsl": case "mnx_mnl": // if image is marked as GFDL-presumed, then user a different user warning template if (document.getElementById("GFDL-presumed")) warnaction = "mnx_gfdl"; break; case 'mnx_mfud': txt = window.prompt('Please enter the reason why you are disputing the fair use of this image:', ''); if (!txt) { alert('mnx_markNo: Action canceled.'); return; }     break; case "mnx_mrfu": var dt = qid_getUploadDate; if (dt) txt = dt; break; } var uploader = qid_getUploader; if (!uploader) return; qid_openWindow(qid_path + '?title=User_talk:' + uploader                + '&action=edit&fakeaction=mnx_warn&target=' + pagename                 + '&type=' + warnaction); var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; var targetUrl = editlk + '&fakeaction=' + action if (txt) targetUrl += '&txt=' + txt; window.location = targetUrl; }

function mnx_addTemplate(template) { var txt = ''; // this is subst for most cases var editformval = qid_removeTemplate(document.editform.wpTextbox1.value, 'untagged'); var summary; switch (template) { case "nsl": txt = '\n'; case "nsd": summary = "Image is missing source information and will be deleted in seven days if it is not added."; break; case "nld": summary = "Image is missing license information and will be deleted in seven days if it is not added."; break; case "nrd": summary = "Image is missing fair use rationale and will be deleted in seven days if it is not added."; break; case "orfud": summary = "This fair use image is not used in any articles and will be deleted in seven days if it remains so."; break; case "rfu": summary = "This fair use appears to illustrate a subject for which a free image could reasonably be found or created and will be deleted in seven days."; break; case "rfu2": summary = "This fair use appears to illustrate a subject for which a free image could reasonably be found or created and will be deleted in two days."; break; case "dfu": txt =  + getParamValue('txt') + ; summary = "The fair use of this image is disputed."; break; case "bsr": txt = ''; summary = "The source URL given is inadequate."; break; } qid_saveEditForm(txt + '\n' + editformval, summary); }

function mnx_addUserWarningTemplate(type, imagetarget) { qid_checkForRedirect(document.editform.wpTextbox1.value, type); var template; var editSummary; var hasShortNotice = false; var shortimagetarget; if (imagetarget) shortimagetarget = qid_removeNamespace(imagetarget); switch (type) { case "mnx_mns": case "mnx_mnsl": template = "image source"; editSummary = "Warning: image missing source information."; break; case "mnx_mnl": template = "image copyright"; editSummary = "Warning: image missing license information."; break; case "mnx_mnr": template = "Missing rationale"; editSummary = "Warning: image missing fair use rationale."; hasShortNotice = true; break; case "mnx_mor": template = "Orphaned"; editSummary = "The fair use image you uploaded is now orphaned."; hasShortNotice = true; break; case "mnx_mrfu": template = "Replaceable"; editSummary = "The fair use image you uploaded is replaceable by a free one."; imagetarget = shortimagetarget; // hasShortNotice = true; break; case "mnx_mfud": template = "No fair"; editSummary = "The use of a non-free image you uploaded is disputed."; hasShortNotice = true; break; case "mnx_mbsr": template = "bsr-user"; editSummary = "Please provide a better source URL for your image."; break; case "mnx_gfdl": template = "GFDL presumed warning"; editSummary = "Warning: image missing license information."; imagetarget = shortimagetarget; // break; } var editformval = document.editform.wpTextbox1.value; var useShortNotice = false; if (hasShortNotice) useShortNotice = qid_userBeenWarned(editformval, template); var txt =  + imagetarget + ; editformval += '\n' + txt + ' ' + '\n'; qid_saveEditForm(editformval, editSummary); }

function mnx_onload { if (document.getElementById('ca-edit') == null) // not editable by non-admin return; if (wgAction == "view" && wgCanonicalNamespace == "Image") { mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mns\')', mns_text, 'mark-no-source', mns_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mnl\')', mnl_text, 'mark-no-license', mnl_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mnsl\')', mnsl_text, 'mark-no-source-license', mnsl_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mnr\')', mnr_text, 'mark-no-rationale', mnr_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mor\')', mor_text, 'mark-orphaned', mor_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mrfu\')', mrfu_text, 'mark-replaceable', mrfu_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mfud\')', mfud_text, 'mark-disputed', mfud_tooltip); mw.util.addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mbsr\')', mbsr_text, 'mark-base-url', mbsr_tooltip); } var fakeaction = getParamValue('fakeaction');

switch (fakeaction) { case 'mnx_mns': mnx_addTemplate('nsd'); break; case 'mnx_mnl': mnx_addTemplate('nld'); break; case 'mnx_mnsl': mnx_addTemplate('nsl'); break; case 'mnx_mnr': mnx_addTemplate('nrd'); break; case 'mnx_mor': mnx_addTemplate('orfud'); break; case 'mnx_mrfu': var cutoff = new Date(2006, 6, 13); var uploadDate = parseInt(getParamValue('txt')); // this is a number value (UNIX time) if (uploadDate > cutoff.getTime) mnx_addTemplate('rfu2'); else mnx_addTemplate('rfu'); break; case 'mnx_mfud': mnx_addTemplate('dfu'); break; case 'mnx_mbsr': mnx_addTemplate('bsr'); break; case 'mnx_warn': mnx_addUserWarningTemplate(getParamValue('type'), decodeURIComponent(getParamValue('target'))); break; } }

addOnloadHook(mnx_onload);

/** ================================================================================ * ==Automatic speedy tagging== * The actions in this section do one thing: * 1. Add a tag to the image page. */ mred_text = "Mark as redundant image"; mred_tooltip = "Mark this image as redundant (tag for speedy deletion)";

mmi_text = "Mark as missing image"; mmi_tooltip = "Mark as missing image (tag for speedy deletion)";

mmtc_text = "Mark as Move to Commons"; mmtc_tooltip = "Mark as candidate to move to Commons";

mncd_text = "Mark as Commons duplicate"; mncd_tooltip = "Mark as Commons duplicate";

function speedyi_addTemplate(template, imagetarget) { var summary; var usesubst = false; switch (template) { case 'isd': summary = 'Tagging for speedy deletion: Image is redundant to Image:' + imagetarget + '.'; break; case 'missing image': summary = 'Tagging for speedy deletion: Image is missing or corrupt.'; break; case 'Move to Commons': summary = 'Image is a candidate for moving to Wikimedia Commons.'; break; case 'ncd': var commonsimgname = (!imagetarget) ? wgPageName : imagetarget; summary = 'Image is duplicate of Commons image ' + commonsimgname + '.'; usesubst = true; break; }

var txt = ''; var editformval = qid_removeTemplate(document.editform.wpTextbox1.value, 'untagged'); if (template == 'ncd') { // for ncd, remove "Move to Commons" (and variations thereof) template var mtctemplates = new Array('Copy to Wikimedia Commons', 'Move to Commons', 'Move to commons', 'Move to Wikimedia Commons', 'Copy to commons', 'Mtc', 'MtC', 'MTC', 'CWC', 'CtWC', 'CTWC', 'Ctwc'); for (var i = 0; i < mtctemplates.length; i++) { editformval = qid_removeTemplate(editformval, mtctemplates[i]); } }  qid_saveEditForm(txt + '\n' + editformval, summary); }

function speedyi_mark(action) { var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; var xtra = ''; switch (action) { case "speedyi_mred": var dupe = window.prompt('Please enter the name of the image this one is redundant to.', ''); if (!dupe) { alert('speedyi_mark: No image name entered.'); return; }     if (dupe.indexOf('Image:') == 0) { dupe = dupe.substring(6); }     xtra = '&target=' + dupe; break; case "speedyi_mncd": var commonsimg = window.prompt('Please enter the name of the corresponding image on Commons (leave empty if the same name).', ''); if (commonsimg == null) { alert('speedyi_mark: Action canceled.'); return; }     if (commonsimg != '') { xtra = '&target=' + commonsimg; }     break; } window.location = editlk + '&fakeaction=' + action + xtra; }

function speedyi_onload { if (document.getElementById('ca-edit') == null) // not editable by non-admin return; if (wgAction == "view" && wgCanonicalNamespace == "Image") { mw.util.addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mred\')', mred_text, 'mark-redundant', mred_tooltip); mw.util.addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mmi\')', mmi_text, 'mark-missing', mmi_tooltip); mw.util.addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mmtc\')', mmtc_text, 'mark-movecommons', mmtc_tooltip); mw.util.addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mncd\')', mncd_text, 'mark-commons', mncd_tooltip); } var fakeaction = getParamValue('fakeaction'); switch (fakeaction) { case 'speedyi_mred': speedyi_addTemplate('isd', decodeURIComponent(getParamValue('target'))); break; case 'speedyi_mmi': speedyi_addTemplate('missing image'); break; case 'speedyi_mmtc': speedyi_addTemplate('Move to Commons'); break; case 'speedyi_mncd': var target = getParamValue('target'); if (target) target = decodeURIComponent(target); speedyi_addTemplate('ncd', target); break; } }

addOnloadHook(speedyi_onload); /* */

} -->