User:PowerUserPCDude/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:PowerUserPCDude/monobook.css. |
// install [[User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript"></' + 'script>');
importScript('User:AzaToth/twinkle.js');
importScript('User:Ioeth/friendly.js');
importScript('User:TheDJ/Gadget-HotCat.js');
importScript('User:Mr.Z-man/refToolbar.js');
*/
// Adapted from:
//http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Force_edit_summary
// The original value of the edit summary field is stored here
var editsummOriginalSummary = new String();
// A global ref to the dropdown with canned edit summaries
var editsummDropdown = null;
function editsummInitialize()
{
// Save the original value of the edit summary field
editsummOriginalSummary = document.forms.editform.wpSummary.value;
// For convenience, add a dropdown box with some canned edit
// summaries to the form.
var dropdown = document.createElement("select");
dropdown.onchange = new Function("editsummOnCannedSummarySelected()");
editsummAddOptionToDropdown(dropdown,"");
editsummAddOptionToDropdown(dropdown,"add categories");
editsummAddOptionToDropdown(dropdown,"add category");
editsummAddOptionToDropdown(dropdown,"add citation");
editsummAddOptionToDropdown(dropdown,"add external link");
editsummAddOptionToDropdown(dropdown,"add internal link");
editsummAddOptionToDropdown(dropdown,"add quotation");
editsummAddOptionToDropdown(dropdown,"add ref");
editsummAddOptionToDropdown(dropdown,"add section");
editsummAddOptionToDropdown(dropdown,"create redirect page");
editsummAddOptionToDropdown(dropdown,"create stub article");
editsummAddOptionToDropdown(dropdown,"delete external link");
editsummAddOptionToDropdown(dropdown,"delete internal link");
editsummAddOptionToDropdown(dropdown,"delete section");
editsummAddOptionToDropdown(dropdown,"fix broken link");
editsummAddOptionToDropdown(dropdown,"fix case");
editsummAddOptionToDropdown(dropdown,"fix grammar");
editsummAddOptionToDropdown(dropdown,"fix punctuation");
editsummAddOptionToDropdown(dropdown,"fix quote marks");
editsummAddOptionToDropdown(dropdown,"fix spelling");
editsummAddOptionToDropdown(dropdown,"indent");
editsummAddOptionToDropdown(dropdown,"make existing text into link (wikify)");
editsummAddOptionToDropdown(dropdown,"make link into plain text (dewikify)");
editsummAddOptionToDropdown(dropdown,"move section");
editsummAddOptionToDropdown(dropdown,"move unrefd material to talk page");
editsummAddOptionToDropdown(dropdown,"new article");
editsummAddOptionToDropdown(dropdown,"remove repetition");
editsummAddOptionToDropdown(dropdown,"reorder links");
editsummAddOptionToDropdown(dropdown,"sectioning");
editsummAddOptionToDropdown(dropdown,"start article");
var insertBeforeThis = document.forms.editform.wpSummary.nextSibling;
var theParent = insertBeforeThis.parentNode;
theParent.insertBefore(dropdown,insertBeforeThis);
// Store a global ref to it
editsummDropdown = dropdown;
}
function editsummAddOptionToDropdown(dropdown,optionText)
{
var option = document.createElement("option");
var optionTextNode = document.createTextNode(optionText);
option.appendChild(optionTextNode);
dropdown.appendChild(option);
}
// There's a cross-browser issue when accessing the selected text:
// *In Firefox you can use: selectObj.value
// *In IE, you have to use: selectObj.options[selectObj.selectedIndex].text
// *The latter method also works in Firefox
function editsummOnCannedSummarySelected()
{
var idx = editsummDropdown.selectedIndex;
var canned = editsummDropdown.options[idx].text;
var newSummary = editsummOriginalSummary;
if (newSummary.length!=0) newSummary += " - ";
newSummary += canned;
document.forms.editform.wpSummary.value = newSummary;
}
// Prefix the edit summary with "SW" or "CP"
// depending on whether it's a SourceWatch or Congresspedia page.
// To determine this, look for a link to "Template:Congresspedia"
// on the edit page.
function editsummAddSubProjectPrefix()
{
// Using the document.links array and the href prop seems to give
// the best cross-browser results.
var allAnchors = document.links;
if (allAnchors)
{
var prefix = "SW: ";
for (i = 0; i < allAnchors.length; i++)
{
var anchorHref = allAnchors[i].href;
if (anchorHref)
{
if (anchorHref.indexOf('Template:Congresspedia') != -1)
{
prefix = "CP: ";
}
}
}
document.forms.editform.wpSummary.value =
prefix + document.forms.editform.wpSummary.value;
}
}
/*
/* Force preview */
/* by Marc Mongenet, 2006, fr.wikipedia. Modified to work for non-anons by Soxred93 */
/* [[User:Soxred93/forcepreview.js]] */
function forcePreview() {
if (wgAction == "edit")
{
document.getElementById("wpSave").disabled=true;
document.getElementById("wpSave").value = "Save (preview first)";
document.getElementById("wpSave").style.fontWeight = "normal";
document.getElementById("wpPreview").style.fontWeight = "bold";
}
}
addOnloadHook(forcePreview);
// This script changes the "Your signature with timestamp" edit button to use a real em dash instead of two hyphens.
(function () {
var oldAddButton = window.addButton;
if (typeof(oldAddButton) != 'function') return;
window.addButton = function () {
if (arguments.length > 2)
arguments[2] = arguments[2].replace(/^--(~+)$/, '—$1');
oldAddButton.apply(this, arguments);
};
})();
// CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES AND IF SURE DO IT AUTOMATIC:
// *** aut. signing / (automatische Unterschrift) *** [[User:Olliminatore/signing.js]]
// created 23.04.2006 by [[User:Olliminatore]]
// updated 23.04.2006 by [[:en:User:Ilmari Karonen]]
// current version 1.56 13.03.2007
// Interwiki <noinclude>[[de:User:Olliminatore/signing.js]]</noinclude>
//<pre><nowiki>
String.prototype.trim = function(){return this.replace(/^\s*|\s*$/g,"")};
if (typeof usersignature == 'undefined') usersignature = ' --\~\~\~\~\n';
if (typeof regpages == 'undefined') { // list of all none talk pages
var regpages = [
':Village pump',
':Articles for deletion',
':Requests for ',
':Reference desk',
':Deletion review',
':Templates for deletion',
'.*noticeboard.*',
':checkuser',
':arbitration',
':feedback',
':page protection',
'mediation)',
':Bot requests',
':Help desk',
':Editor review',
':Adminship survey',
':Cleanup',
':Miscellany for deletion',
':New contributors\' help page',
':Media copyright questions'
];
}
// regarded pages type encoded
if (wgCanonicalNamespace.match(/talk$/i)) var regpages = "";
for (p in regpages) if (wgPageName.indexOf(regpages[p]) != -1){regpages=false; break}
if (!regpages)
addOnloadHook(function(){
if (!(window.editform = document.forms['editform'])) return;
// Add a new checkbox to the Wiki editOptions.
sigBox = document.createElement("input");
sigBox.setAttribute('type','checkbox');
sigBox.setAttribute('name','wpSigning');
sigBox.setAttribute('id','wpSigning');
sigBox.setAttribute('checked','checked');
sigBox.defaultChecked=true;
neuB = document.createElement("label");
neuB.appendChild(sigBox);
neuB.appendChild(document.createTextNode("Sign"));
neuB.setAttribute('for','wpSigning');
neuB.setAttribute('title','Sign this edit automatic.');
function setSigBox() { // switch enable box
if (editform.wpMinoredit.checked) sigBox.setAttribute('disabled','disabled');
else sigBox.removeAttribute('disabled');
};
var txtarea=editform.elements['wpTextbox1'];
var txtOld=txtarea.value.trim();
// txtOld_l=txtOld.length
var txtOldEnd=txtOld.slice(-24);
var sig = /~{3}/g;
if (!tNode){
//editform.insertBefore(neuB, editform.elements['wpWatchthis']); // maybe FIXME: raised an NS_DOM_ERR!
var tNode = editform.elements['wpMinoredit'].parentNode; // DOM workaround!?
tNode.divs = tNode.getElementsByTagName("DIV");
tNode.divs = tNode.divs.item(tNode.divs.length-1); // last div
tNode.insertBefore(neuB, tNode.divs);
setSigBox();
}
function doSign(event){
if(editform.onsubmit==''){ // only once!
removeEvent(editform.wpSave,"click",doSign);
removeEvent(editform.wpPreview,"click",doSign);
}
if(editform.onsubmit=='') removeEvent(editform.wpSave,"click",doSign); // only once!
if(editform.wpMinoredit.checked || !sigBox.checked) return;
txtarea.focus();
var cOld = txtOld.match(/<nowiki>.*?~{3}.*?<\/nowiki>/g); // exception for nowiki
if (cOld) cOld = cOld.length;
cNew = txtarea.value.match(sig); if (cNew) cNew = cNew.length;
if (cNew > cOld){ // if there are a sign, check for true
var cNew2 = txtarea.value.match(/\{\{subst\:unsig.*?~{3}\}\}/); // exception for Template:unsigned
cNew -= (cNew2)?cNew2.length:0;
}
if(cNew <= cOld){ // if nothing then search a set position
txt=txtarea.value.trim();
txtEnd=txt.slice(-24);
if(txtOldEnd!=txtEnd) return txtarea.value = txt + usersignature; // aut. underwrite
else { // post between
pos = getCaretPos(txtarea);
pos = txt.indexOf('\n', pos); // go to the post-end
txtEnds = txt.substr(pos,24).replace(/(^\s*)/,""); // after
txtpEnds = txt.slice(pos-18,pos); // before
oldp = txtOld.indexOf(txtEnds);
if(oldp!=-1 && oldp < pos - 3 && txtOld.indexOf(txtpEnds+RegExp.$1+txtEnds)==-1) // if some added
return txtarea.value = txt.slice(0,pos).trim() + usersignature + txt.slice(pos+1);
}
// FIXME: then the edit-end is not found!?
}
else if(!sig.test(txtOld) || cOld < cNew) return;
if (event) event=(window.Event)? event.target: event.srcElement;
if (event.name == 'wpPreview') return; // not for preview
return editform.onsubmit=new Function("editform.onsubmit='';"
+"return confirm('No signing was found. Continue anyway?')"); //warn if saving without signature
};
addEvent(editform.wpSave,"click", doSign);
addEvent(editform.wpPreview,"click", doSign);
addEvent(editform.wpMinoredit,"click", setSigBox);
});
function getCaretPos(txtObj){
if (txtObj.setSelectionRange) return txtObj.selectionStart; // NS like
else if(!document.selection) return 0; // not IE like
var c="\001", pos=0;
var range=document.selection.createRange();
var txt=range.text, dul=range.duplicate();
dul.moveToElementText(txtObj);
range.text=txt+c;
pos=(dul.text.indexOf(c));
range.moveStart('character',-1);
range.text="";
return pos;
};
/* add/removeEvent Original idea by John Resig
Tweaked by Scott Andrew LePera, Dean Edwards and Peter-Paul Koch
Fixed for IE by Tino Zijdel (crisp) @date 2005-10 */
function addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false)}else if(obj.attachEvent){var eProp=type+fn;obj["e"+eProp]=fn;obj[eProp]=function(){obj["e"+eProp](window.event)};obj.attachEvent("on"+type,obj[eProp])}else{obj['on'+type]=fn}};
function removeEvent(obj,type,fn){if(obj.removeEventListener){obj.removeEventListener(type,fn,false)}else if(obj.detachEvent){var eProp=type+fn;obj.detachEvent("on"+type,obj[eProp]);obj['e'+eProp]=null;obj[eProp]=null}else{obj['on'+type]=null}};
// *** end *** </nowiki></pre>
sigAccessKey = ',';
sigText = '— ~~' + '~~'; //dash instead of --
importScript('Wikipedia:WikiProject User scripts/Scripts/qSig');
if (wgAction == 'history') //add a link to call histComb.js
addOnloadHook(function(){
var pagehis = document.getElementById('pagehistory');
if (!pagehis) return;
var lnk = document.createElement('a');
lnk.style.marginLeft = '10px';
lnk.href = '#';
lnk.appendChild(document.createTextNode('Improve…'));
lnk.onclick=function(){this.parentNode.removeChild(this);importScript('User:Alex_Smotrov/histcomb.js')}
pagehis.parentNode.insertBefore(lnk, pagehis);
})
// <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked for wikification" as the edit summary, mark it as a minor edit, and submit.</nowiki>
function doQwikify() {
document.editform.wpTextbox1.value = '{' + '{' + 'Wikify|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'Marked for wikification';
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
addOnloadHook(function() {
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
// wouldn't it make more sense to just check for wgCanonicalNamespace != "", or am I missing something?
return;
}
if (document.editform) {
addPortletLink("p-cactions", "javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", "");
}
});
// by [[User:Raylu|raylu]]
//
// <nowiki>If you are editing a page, click the unref button on your tab bar to add "{{Unreferenced|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked as unreferenced" as the edit summary, mark it as a minor edit, and submit.
function doQunref() {
document.editform.wpTextbox1.value = '{' + '{' + 'Unreferenced|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'Marked as unreferenced.';
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
addOnloadHook(function() {
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
return;
}
if (document.editform) {
addPortletLink("p-cactions", "javascript:doQunref()", "unref", "ca-unref", "Mark as unreferenced", "");
}
});
// by [[User:Jj137|jj137]]
//
// CleanupTab.js
//
// This script adds a "cleanup" tab to the top of article pages
// when in edit mode. It is disabled for the User namespace.
function doCleanup() {
document.editform.wpTextbox1.value = '{' + '{' + 'Cleanup|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'Marked for cleanup.';
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
addOnloadHook(function() {
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
return;
}
if (document.editform) {
addPortletLink("p-cactions", "javascript:doCleanup()", "cleanup", "ca-cleanup", "Mark for cleanup", "");
}
});
//
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;
}
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:" + "test" + number + "-n|" + page + "}} ~" + "~" + "~" + "~";
f.wpSummary.value = "Vandalism to [[" + page + "]] - warning " + number;
}
function add_testn_tabs()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
// Only add for pages with "Editing User talk:" somewhere in the title
if (document.title.indexOf("Editing User talk:") != -1)
{
tabs.appendChild(tnaddlilink('javascript:testn(1)',"t1"));
tabs.appendChild(tnaddlilink('javascript:testn(2)',"t2"));
tabs.appendChild(tnaddlilink('javascript:testn(3)',"t3"));
tabs.appendChild(tnaddlilink('javascript:testn(4)',"t4"));
}
}
addOnloadHook(add_testn_tabs);
//
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;
}
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 = "Vandalism to [[" + page + "]] - warning " + number;
f.submit();
}
function wA() {
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "welcome-anon-from|Where" + "}} ~" + "~" + "~" + "~";
f.wpSummary.value = "Welcome to Wikipedia!";
f.submit();
}
function wap() {
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "User:Where/pwelcome" + "}} ~" + "~" + "~" + "~";
f.wpSummary.value = "Use preview; also, welcome!";
f.submit();
}
function es() {
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "==Edit summaries==\n{{subst:" + "Edit summary" + "}} ~" + "~" + "~" + "~";
f.wpSummary.value = "Please use edit summaries";
f.submit();
}
function add_testn_tabs()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
// Only add for pages with "Editing User talk:" somewhere in the title
if (document.title.indexOf("Editing User talk:") != -1)
{
tabs.appendChild(tnaddlilink('javascript:es()', "ES"));
tabs.appendChild(tnaddlilink('javascript:testn("test1")',"t1"));
tabs.appendChild(tnaddlilink('javascript:testn("test1a")',"t1a"));
tabs.appendChild(tnaddlilink('javascript:testn("test2")',"t2"));
tabs.appendChild(tnaddlilink('javascript:testn("test2a")',"t2a"));
tabs.appendChild(tnaddlilink('javascript:testn("test3")',"t3"));
tabs.appendChild(tnaddlilink('javascript:testn("test4")',"t4"));
tabs.appendChild(tnaddlilink('javascript:testn("bv")',"bv"));
tabs.appendChild(tnaddlilink('javascript:testn("obscene")',"o"));
tabs.appendChild(tnaddlilink('javascript:testn("joke")',"j"));
tabs.appendChild(tnaddlilink('javascript:testn("welcomenpov")',"w-N"));
tabs.appendChild(tnaddlilink('javascript:wA()',"w-A"));
tabs.appendChild(tnaddlilink('javascript:wap()',"w-A-p"));
}}
addOnloadHook(add_testn_tabs);
*/
function unverified() {
// Find the edit box
var txt = document.editform.wpTextbox1;
// The tag to be included is an unverified image template
var tag = '{{unverified|day={{subst:CURRENTDAY2}}|month={{subst:CURRENTMONTH}}}}';
// If the edit box doesn't already have this tag...
if (txt.value.indexOf(tag) == -1) {
// Append the tag
txt.value += tag;
// Add an edit summary
document.editform.wpSummary.value = 'Needs a source and copyright tag — see [[Wikipedia:Image copyright tags]]';
// Press the Save page button
document.editform.submit();
}
// If the tag was already there, turn the tab background red to indicate
// that the script is functioning properly, but that there is no action
// to do. This doesn't interrupt the user's work like an alert() would.
else {
document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444";
document.getElementById('ca-unverified').style.backgroundColor = "#ff4444";
}
}
// Create a tab that calls this function when pressed
addOnloadHook(function () {
if(document.title.indexOf("Editing Image:") == 0) {
addPortletLink('p-cactions', 'javascript:unverified()', 'tag', 'ca-unverified', 'Adds a tag to an unverified image', '', '');
}
});
/*
*/
//On diff pages this script replaces ''(Difference between revisions)''with
//different tools for reverting the edit and warning the user that made the edit.
//For instructions see talk page.
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
// Function from http://www.dustindiaz.com/getelementsbyclass/
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
var _temp_get_arr_1 = new Array();
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
function getMessage (where, user1, user2) {
var message = prompt ('What message would you like to leave?', '');
window.location = 'http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
addOnloadHook(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
document.getElementById('contentSub').innerHTML = '(<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Revert</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalism</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Warn: <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=1">Test</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=2">Blatant</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=3">Nonsense</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=4">Blanking</a>)';
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = 'Reverted edits by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = 'Reverted edits by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=1/)) {
document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=2/)) {
document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:blatantvandal}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test2}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=4/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test2a}} ~~'+'~~';
document.getElementById('editform').submit();
}
});
/*
/* <pre><nowiki> */
/* quickimgdelete.js
* Current version: 1.12
* =======================================
* Created by [[User:Howcheng|Howard Cheng]]
* Released under the [[GNU Public License]] (GPL)
* Full documentation at [[User talk:Howcheng/quickimgdelete.js]]
* =======================================
*/
// ==General configuration==
if (typeof(qid_alwaysOpenNew) == 'undefined') { qid_alwaysOpenNew = false; } // Should alerts always spawn new windows? (otherwise they get reused)
if (typeof(qid_autoSave) == 'undefined') { qid_autoSave = true; } // Should the edits be saved automatically?
// ==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 userIsInGroup(groupName) {
for (var i = 0; i < wgUserGroups.length; i++) {
if (wgUserGroups[i] == groupName)
return true
}
return false;
}
function qid_openWindow(url, windowName) {
if (!windowName) windowName = 'qid_window';
var res = (!qid_alwaysOpenNew) ? window.open(url, windowName) : window.open(url);
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() == 'table')
break;
}
if (!el) {
alert("qid_getFileHistory: Cannot find TABLE tag ... exiting");
return null;
}
var trs = el.getElementsByTagName('tr');
if (!trs) {
alert("qid_getFileHistory: Cannot find TR tags ... exiting");
return null;
}
return trs;
}
function qid_getUploader() {
// Returns title of user page (without name space) in URL form
var trs = qid_getFileHistory();
var els = new Array();
var tr = trs[0]; // skip first one because it's the header
do {
tr = tr.nextSibling;
var tds = tr.childNodes;
var td = tds[(userIsInGroup("sysop") ? 5 : 4)]; // uploader info
els[els.length] = td;
} while (tr.nextSibling);
var uploaders = new Array();
var re1 = new RegExp('http://' + (window.location.hostname + '/wiki/').replace(/\./g, '\\.') + 'User:(.*)$');
var re2 = new RegExp('http://' + (window.location.hostname + wgScript).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;
for (var i = 0; i < els.length; i++) {
var el = els[i];
if (!el) continue;
var as = el.childNodes;
if (!as) continue;
for (var k=0; k<as.length; k++) {
if (as[k].tagName != 'A') continue;
m = re3.exec(as[k].title);
if (m) uploader = encodeURIComponent(m[2]);
m = re1.exec(as[k].href);
if (m) uploader = m[1];
m = re2.exec(as[k].href);
if (m) uploader = m[1];
if (uploader) break;
}
if (uploaderList.indexOf(uploader) == -1) {
if (count > 0) uploaderList += "; ";
uploaderList += count + " - " + uploader;
uploaders[uploaders.length] = uploader;
count += 1;
}
}
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 trs = qid_getFileHistory();
var els = new Array();
var tr = trs[0]; // skip first one because it's the header
do {
tr = tr.nextSibling;
var tds = tr.childNodes;
var td = tds[(userIsInGroup("sysop")) ? 2 : 1]; // date info
els[els.length] = td;
} while (tr.nextSibling);
var re = /\d{2}:\d{2}, \d+ [a-z]+ \d{4}/i;
var m;
var dt;
for (var i = 0; i < els.length; i++) {
var el = els[i];
if (!el) continue;
var as = el.childNodes;
if (!as) continue;
for (var k=0; k<as.length; k++) {
if (as[k].tagName != 'A') continue;
m = (as[k].text) ? re.exec(as[k].text) : re.exec(as[k].innerText);
if (m) dt = m[0];
if (dt) {
try {
var ret = Date.parse(dt);
return ret; // ret is a number value (UNIX time)
} catch (someError) {
}
}
}
}
return null;
}
function qid_removeTemplate(editformval, template) {
var templatepos = editformval.indexOf('{{' + template);
if (templatepos > -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 = wgScript + '?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("/\<!-- ?Template:" + template + " ?--\>/;");
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(wgPageName);
var uploader = qid_getUploader();
if (!uploader) return;
qid_openWindow(wgScript + '?title=User_talk:' + uploader
+ '&action=edit&fakeaction=' + which + '_warn&target=' + pagename);
qid_openWindow(wgScript + '?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 = '{{' + template;
var summary;
switch (template) {
case nfd_deleteTemplate:
txt += '|log=' + GuessUTCDate();
summary = 'nomination for [[WP:IFD|deletion]]';
break;
case pui_deleteTemplate:
txt += '|log=' + GuessUTCDate();
summary = 'this is a [[WP:PUI|possibly unfree image]]';
break;
case vio_deleteTemplate:
summary = 'this image is suspected to be a [[WP:CP|copyright violation]]';
txt += '|1=' + otherparam;
break;
}
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 = '{{subst:' + template + '|1=' + 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 = '{{subst:' + nfd_ifdTemplate + '|1=' + imageName +
'|Uploader=' + uploader + '|Reason=' + reason + '}}';
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 = '{{subst:' + pui_ifdTemplate + '|image=' + imageName +
'|reason=' + reason + '}}';
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 = '* {{subst:Image-cv|1=' + 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") {
addPortletLink('p-tb', 'javascript:nfd_tagImage(\'nfd\')', nfd_text, 'nom-for-del', nfd_tooltip);
addPortletLink('p-tb', 'javascript:nfd_tagImage(\'pui\')', pui_text, 'pui', pui_tooltip);
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 non-free rationale";
mor_text = "Orphaned non-free";
mor_tooltip = "Mark this image as an orphaned non-free image";
mrfu_text = "Replaceable non-free";
mrfu_tooltip = "Mark this image as a replaceable non-free image";
mfud_text = "Non-free use disputed";
mfud_tooltip = "Mark this image as non-free 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(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 use 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 usage of this non-free 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(wgScript + '?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 = '{{subst:' + template + '}}'; // this is subst for most cases
var editformval = qid_removeTemplate(document.editform.wpTextbox1.value, 'untagged');
var summary;
switch (template) {
case "nsl":
txt = '{{subst:nsd}}\n{{subst:nld}}';
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 non-free usage rationale and will be deleted in seven days if it is not added.";
break;
case "orfud":
summary = "This non-free image is not used in any articles and will be deleted in seven days if it remains so.";
break;
case "rfu":
summary = "This non-free image appears to illustrate a subject for which a free one could reasonably be found or created and will be deleted in seven days.";
break;
case "rfu2":
summary = "This non-free image appears to illustrate a subject for which a free one could reasonably be found or created and will be deleted in two days.";
break;
case "dfu":
txt = '{{subst:' + template + '|1=' + getParamValue('txt') + '}}';
summary = "The usage of this non-free image is disputed.";
break;
case "bsr":
txt = '{{' + template + '}}';
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 dropNamespace = false;
switch (type) {
case "mnx_mns":
case "mnx_mnsl":
template = "Di-no source-notice";
editSummary = "Warning: image missing source information.";
dropNamespace = true;
break;
case "mnx_mnl":
template = "Di-no license-notice";
editSummary = "Warning: image missing license information.";
dropNamespace = true;
break;
case "mnx_mnr":
template = "Missing rationale";
editSummary = "Warning: image missing non-free usage rationale.";
hasShortNotice = true;
break;
case "mnx_mor":
template = "Orphaned";
editSummary = "The non-free image you uploaded is now orphaned.";
hasShortNotice = true;
break;
case "mnx_mrfu":
template = "Replaceable";
editSummary = "The non-free image you uploaded is replaceable by a free one.";
dropNamespace = true;
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.";
dropNamespace = true;
break;
}
var editformval = document.editform.wpTextbox1.value;
var useShortNotice = false;
if (hasShortNotice)
useShortNotice = qid_userBeenWarned(editformval, template);
var txt = '{{subst:' + template;
if (useShortNotice)
txt += ' short';
if (dropNamespace && imagetarget)
imagetarget = qid_removeNamespace(imagetarget);
txt += '|1=' + 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") {
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mns\')', mns_text, 'mark-no-source', mns_tooltip);
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mnl\')', mnl_text, 'mark-no-license', mnl_tooltip);
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mnsl\')', mnsl_text, 'mark-no-source-license', mnsl_tooltip);
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mnr\')', mnr_text, 'mark-no-rationale', mnr_tooltip);
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mor\')', mor_text, 'mark-orphaned', mor_tooltip);
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mrfu\')', mrfu_text, 'mark-replaceable', mrfu_tooltip);
addPortletLink('p-tb', 'javascript:mnx_markNo(\'mnx_mfud\')', mfud_text, 'mark-disputed', mfud_tooltip);
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 [[WP:CSD#I1|speedy deletion]]: Image is redundant to [[:Image:' + imagetarget + ']].';
break;
case 'missing image':
summary = 'Tagging for [[WP:CSD#I2|speedy deletion]]: Image is missing or corrupt.';
break;
case 'Move to Commons':
summary = 'Image is a candidate for moving to [[Commons:Main Page|Wikimedia Commons]].';
break;
case 'ncd':
var commonsimgname = (!imagetarget) ? wgPageName : imagetarget;
summary = 'Image is duplicate of [[Commons:Main Page|Commons]] image [[Commons:' + commonsimgname + '|]].';
usesubst = true;
break;
}
var txt = '{{' + (usesubst ? 'subst:' : '') + template;
if (template == 'isd' || (template == 'ncd' && imagetarget)) {
txt += '|1=' + imagetarget;
}
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") {
addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mred\')', mred_text, 'mark-redundant', mred_tooltip);
addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mmi\')', mmi_text, 'mark-missing', mmi_tooltip);
addPortletLink('p-tb', 'javascript:speedyi_mark(\'speedyi_mmtc\')', mmtc_text, 'mark-movecommons', mmtc_tooltip);
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);
/* </nowiki></pre> */
/**** welcome new user ****/
document.write('<script type="text/javascript"' +
'src="http://en.wikipedia.org/w/index.php?title=User:Nmajdan/welcome_newuser.js' +
'&action=raw&ctype=text/javascript&dontcountme=s"></script>');
// <nowiki>If you are editing a page, click the welcome button on your tab bar to add "{{subst:welcome}} ~~~~" to the top, set "Welcome to Wikipedia!" as the edit summary, and submit.
function doQwelcome() {
document.editform.wpTextbox1.value = '{' + '{' + 'subst:welcome + '}' + '}' + ' ~~~~'\n\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'Welcome to Wikipedia!';
document.editform.wpMinoredit.checked = false;
document.editform.submit();
}
addOnloadHook(function() {
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "Talk" || wgCanonicalNamespace == "Main" || wgCanonicalNamespace == "Wikipedia" || wgCanonicalNamespace == "Wikipedia_talk" || wgCanonicalNamespace == "Image" || wgCanonicalNamespace == "Image_talk" || wgCanonicalNamespace == "MediaWiki" || wgCanonicalNamespace == "MediaWiki_talk" || wgCanonicalNamespace == "Template" || wgCanonicalNamespace == "Template_talk" || wgCanonicalNamespace == "Help" || wgCanonicalNamespace == "Help_talk" || wgCanonicalNamespace == "Category" || wgCanonicalNamespace == "Category_talk" || wgCanonicalNamespace == "Portal" || wgCanonicalNamespace == "Portal_talk") {
return;
}
if (document.editform) {
addPortletLink("p-cactions", "javascript:doQwelcome()", "welcome", "ca-welcome", "Welcome user", "");
}
});
// by [[User:Jj137|jj137]]
//
importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');
importScript('User:S/tags.js');
importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');
importScript('User:LilDice/flexitags.js');
// Stub tag tab. Original version by [[User:ais523]], on a request by [[User:thesublime514]].
// Enhancements made on requests by [[User:Alai]] and [[User:jj137]].
// ([[User:ais523/stubtagtab2.js]])
// <source lang="javascript">
addOnloadHook(function(){
if(wgNamespaceNumber==0&&wgAction=="view")
{
if(document.getElementById("ca-edit"))
addPortletLink('p-cactions', 'javascript:stubtagtab()', 'stub', 'ca-stubtag',
'Add a stub tag to this page', '');
}
if(location.href.indexOf("&autoaddstubtag=")!=-1&&document.getElementById('wpTextbox1')!=null)
{
var x=decodeURIComponent(location.href.split("&autoaddstubtag=")[1]);
if(x.indexOf("-stub")==-1) x+="-stub";
document.getElementById('wpTextbox1').value+="\n{"+"{"+x+"}}"; //add to the end of the article
document.getElementById('wpSummary').value=
"Tagging with {"+"{"+x+"}} using [[WP:US/S|user scripts]]";
document.getElementById('wpPreview').click();
}
});
function stubtagtab()
{
var h;
// A list of subpages of WikiProject Stub sorting/Stub types/ that are relevant to this
var a=['Commerce','Culture','Education','Geography','Government, law, and politics','History',
'Leisure','Military and weaponry','Miscellaneous','Organizations','People',
'Religion, mythology, faiths, and beliefs','Science','Sports','Technology','Transport'];
var i=0;
h="<div style='color:#000000; background-color:#fff8f8;'>• ";
while(i<a.length)
{
h+="<a href='javascript:stubtagmenu(\""+a[i]+"\");'>"+a[i]+"</a> • ";
i++;
}
h+="</div><div id='stubtagmenudiv' style='color:#000000; background-color:#fffff8;'></div>";
document.getElementById("contentSub").innerHTML=h;
}
function stubtagmenurender(a)
{
if(a.responseText.indexOf("<text>")==-1)
{
document.getElementById('stubtagmenudiv').innerHTML=
"<i>Loading, please wait...</i>";
return;
}
var s=a.responseText.split("<text>")[1].split("</text>")[0];
s=s.split("<").join("<").split(">").join(">");
s=s.split(""").join('"').split("&").join('&');
s=s.split('<a href="/wiki/Template:');
var i=s.length;
while(--i) s[i]=s[i].split('" title').join('\');" title');
s=s.join('<a temphref="javascript:stubtagwith(\'');
s=s.split('<a href=').join('<a style="color:#000000;" notanhref=');
s=s.split('<a temphref=').join('<a href=');
document.getElementById('stubtagmenudiv').innerHTML=s;
}
function stubtagmenu(x)
{
//Fetch the relevant subpage of the WikiProject
var a = sajax_init_object();
a.open('GET', wgServer+wgScriptPath+'/api.php?action=parse&prop=text&text='+
encodeURIComponent('__NOTOC____NOEDITSECTION__{{Wikipedia:WikiProject Stub sorting/Stub types/'+
x+'}}')+'&format=xml');
a.onreadystatechange = function(){stubtagmenurender(a)};
a.send('');
}
function stubtagwith(x)
{
if(x==null||x=="") return;
location.href=wgServer+wgScript+"?title="+encodeURIComponent(wgPageName)+
"&action=edit&autoaddstubtag="+encodeURIComponent(x);
}
// </source> <!--[[Category:Wikipedia scripts]]-->
//FastButtons 1.0
importScript('User:Macy/FastButtons.js');
// addPurge
addOnloadHook(function () {
var hist; var url;
if (!(hist = document.getElementById('ca-history') )) return;
if (!(url = hist.getElementsByTagName('a')[0] )) return;
if (!(url = url.href )) return;
addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
'purge', 'ca-purge', 'Purge server cache for this page', '0');
});
//
// Please leave the following line
// [[user:Where/usertabs]]
addOnloadHook(function() {
if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history
return;
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
var username = encodeURIComponent( wgTitle );
addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions");
addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "Edit count", "ca-editcount", "Edit count from Interiot's Tool1");
addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user");
addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user");
addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace");
addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user");
addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user");
addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user");
}
});
//
addOnloadHook(function() {
if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history
return;
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
var username = encodeURIComponent( wgTitle );
addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "contribs", "ca-contrib", "User contributions");
addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "count", "ca-editcount", "Edit count from Interiot's Tool1");
addPortletLink("p-cactions", "http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=" + username + "&site=en.wikipedia.org", "Summary", "ca-summary", "Edit Summary");
}
});
//
if (wgNamespaceNumber >= 0)
addOnloadHook(function(){
var pCactions = document.getElementById('p-cactions');
if (!pCactions) return;
var caMain = pCactions.getElementsByTagName('li')[0];
var caTalk = document.getElementById('ca-talk');
var caEdit = document.getElementById('ca-edit');
if (!caEdit) caEdit = document.getElementById('ca-viewsource');
var caHistory = document.getElementById('ca-history');
if (!caMain || !caTalk || !caEdit || !caHistory) return;
var el_move, el_create, id2;
if (wgNamespaceNumber % 2) { //talk space
el_move = caTalk; el_create = caMain; id2 = '';
} else {
el_move = caMain; el_create = caTalk; id2 = 'discussion';
}
caEdit.firstChild.innerHTML = 'edit';
caHistory.firstChild.innerHTML = 'hist';
el_move.parentNode.insertBefore(caHistory, el_move.nextSibling);
el_move.parentNode.insertBefore(caEdit, el_move.nextSibling);
var href = el_create.firstChild.getAttribute('href', 2);
if (el_create.className.indexOf('new') < 0){
addPortletLink('p-cactions', href + '?action=history', 'hist',
'ca-history-'+id2, id2+' history', '', el_create.nextSibling);
addPortletLink('p-cactions', href + '?action=edit', 'edit',
'ca-edit-'+id2, 'Edit '+id2, '', el_create.nextSibling);
}
caMain.style.marginRight = '0.3em';
caTalk.style.marginRight = '0.3em';
caTalk.style.marginLeft = '1.6em';
})
//
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Csörföly D/lastfm.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
importScript('User:JeremyMcCracken/contribstab.js');
Script version 2.2.1
Versions 1.0-2.0 in history of [[User:Sceptre/monobook.js]]... I think
*/
function warn()
{
var txt = document.editform.wpTextbox1;
var prefix = prompt("What is the prefix? Change if appropriate", "uw-")
var type = prompt("Which standard warning do you wish to issue?", "test");
var severity = prompt("How severe is the violation?", "1");
var page = prompt("What page?");
var msgtext = "{{subst:"+prefix + type + severity + "|" + page + "|subst=subst:}} ~~~~";
if(page.length == 0) {page = "Wikipedia"} else { page = "[["+page+"]]" };
var summary = "Your recent edits to " + page ;
document.editform.wpSummary.value = summary;
document.editform.wpMinoredit.checked = true;
if(txt.value.length > 0) txt.value += '\n';
txt.value += msgtext;
document.editform.submit();
}
/*