User:Memo18/global.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * Forces left-to-right layout and editing on RTL wikis.
 * @see https://meta.wikimedia.org/wiki/Force_ltr
 * @update-token [[File:pathoschild/forceltr.js]]
 */
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.forceltr.js');

/**
 * Ajax sysop
 * @see https://meta.wikimedia.org/wiki/Ajax_sysop
 * @update-token [[File:pathoschild/ajaxsysop.js]]
 */
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.ajaxsysop.js');

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:pathoschild/templatescript.js]]
 */
// <nowiki>
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add([
		{ name: 'SupportWP', template: '{{2009/Donate-header/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n{{2009/Donate-home-nochapter\n| intro-text1 = This is where we protect Wikipedia, the encyclopedia written by the people.\n| intro-text2 = Wikipedia is a nonprofit project that exists for one reason: the free and open sharing of knowledge.<br />\nYour donations keep Wikipedia going.\n| near-you-title = What’s Wikipedia doing near you?\n| near-you-text =\nThe [[2009/Donate/en|Wikimedia movement]] has already made a significant impact throughout the world.<br />\n[http://wikimedia.org Wikimedia] is building an international network of associated organizations.<br />\nThere are currently [[2009/Donate/Chapters/en|27 Wikimedia chapters]].<br />\n[[2009/Donate/Chapters/en|Learn more]].\n| story-title = Wikipedia founder Jimmy Wales\n| story-text = "It stopped being just a website a long time ago. For many of us, most of us, Wikipedia has become an indispensable part of our daily lives."\n| story-text-link = Help protect it now. Please make a donation today.\n| comments-title = Donor comments\n| comments-text =\n"I\'m a professional \'knowledge worker\' & am often under time pressure -- I\'ve come to rely on Wikipedia for intelligent & detailed overviews of unfamiliar topics."<br />\n[[Special:ContributionHistory/en|Read more]].\n| faq-title = FAQs\n| faq-text =\nWhere does my money go? People and technology. Even though Wikipedia is one of the top 5 most visited websites in the world, we employ fewer than 35 people.<br />\n[[FAQ/en|Learn more]].\n| donate-now-title = Make your donation now\n| donate-now-content =\n{{2009/Donate-now\n| donate-now-intro = Wikipedia is nonprofit and relies on your individual donations. Please make your donation now. \n| gift-amount-text = Select your tax-deductible gift amount:\n| matching-text = <sup>[*]</sup>All gifts of $100 or more will be matched by Omidyar Network for a limited time. To learn more, [[FAQ/en#What_is_the_Omidyar_Network.3F|click here]].\n| button-color = button-navyblue\n| red-button-label = Donate by credit card\n| red-button-label2 = Donate via PayPal\n| other-ways-link = [[Ways_to_Give/en|Other ways to give]]<br />\n| amount-title =\n| public-comment-title = Public comment\n| public-comment-instructions = Have a thought to share with the world?  Put up to 200 characters here:\n| donor-choice = Please list my name (next to my comment) on the public donor list.\n| email-option = I agree to receive future Wikimedia Foundation newsletters or emails. (We will never sell or trade your information.  Our privacy policy can be found [[Donate/Donor_Privacy|here]].)\n| non-profit-text = For more information about our non-profit status, our Annual Report, or other questions, [[FAQ/en|click here]].\n| give-to-chapter-text=To give to a local Wikimedia chapter, [[Chapters/en|click here]].\n| non-js-text = To give using IE6 or last year\'s form, please [[DonateNonJS/en|click here]].\n| donate-amount-0 = {{{alternate-amount-3|100}}}\n| donate-amount-1 = {{{alternate-amount-2|75}}}\n| donate-amount-2 = {{{alternate-amount-1|50}}}\n| donate-amount-3 = {{{alternate-amount-0|35}}}\n| donate-amount-other = Other:\n| donate-currency = USD\n| donate-currency-symbol = $\n| language = en\n| landing-page = {{{alternate-landing|Support}}}\n| validation-error = You must enter a valid amount.\n| validation-error-minimum = You must contribute at least $1\n}}\n}}\n{{2009/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Thanks to translators from Meta: [[m:Fundraising 2008/core messages]]' },
		{ name: 'ThankYou', template: '{{2009/Donate-header/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n{{2009/Donate/Thankyou\n| jimmy-quote = <span style="font-weight: bold;">Thank you.</span> Imagine if every person on earth could share in the free and total access to all human knowledge. <span style="color:black">Your donation</span> helps get us closer. \n| jimmy-sig = Jimmy Wales, Founder of Wikipedia\n| share-title = Send this email to friends\n| share-intro = Enter email addresses\n| share-subject = Join me in supporting Wikipedia Forever!\n| share-message = "Imagine if every person on earth could share in the free and total access of all human knowledge. That’s why I gave to the Wikimedia Foundation. Please join me in supporting Wikipedia."\n| story-title = Please tell us your Wikipedia story\n| story-links = Read other [[Stories2/en|Wikipedia stories]] and [[Special:ContributionHistory/en|donor comments]].\n| story-intro = What does Wikipedia Forever mean to you?\n| story-name = Name:\n| story-city = City:\n| story-email = Email:\n| story-your-story = Your story:\n| story-permission =\nBy checking this box you grant the Wikimedia Foundation permission to follow-up with you directly regarding your story. We will seek your full permission before publicizing or discussing your story publicly.\n| story-submit = Submit\n| support-title = Show your support for Wikimedia\n| support-intro = Download these buttons and banners for your website, blog or social networking page.\n| support-link = [[Support/en|See more]]\n| language = en\n}}\n{{2009/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Thanks to translators from Meta: [[m:Fundraising 2008/core messages]]' },
		{ name: 'Now', template: '{{2008/Donate-header/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n{{Template:2008/Donate-now\n|support-wikipedia-title=<!--1 (with Wikimedia)-->\n|paypal-text=<!--91-->\n<!--92-->\n|red-button-label=<!--98-->\n|amount-title=<!--93-->\n|public-comment-title=<!--94 part 1-->\n|public-comment-instructions=<!--94 part 2-->\n|donor-choice=<!--96a-->\n|email-option=<!--97--> [[privacy_policy|here]].\n|credit-card-text=<!--99-->\n|non-profit-text=<!--100--> [[Donate/Transparency/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}|click here]].\n|give-to-chapter-text=<!--101--> [[Donate/Chapters/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}|click here]].\n\n|donate-amount-1=30\n|donate-amount-2=75\n|donate-amount-3=100\n|donate-amount-other=<!--String not localized yet (optional)-->\n|donate-currency=USD\n|donate-currency-symbol=$\n|language={{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}\n}}\n{{2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Thanks to translators from Meta: [[m:Fundraising 2008/core messages]]' },
		{ name: 'Support', template: '{{2008/Donate-header/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n{{Template:2008/Donate-thankyou\n|page-title=<!--110-->\n|confirmation-email=<!--111-->\n|support-wikipedia-title=<!--113-->\n|support-wikipedia-text=<!--114--> [[:Image:Wiki puzzle.svg|here]]\n|copy-code-text=Copy the code below to embed this button on your website. <!--String not localized yet-->\n|banner-style=<!--120-->\n|small-button=<!--121-->\n|extended-button=<!--122-->\n|story-text=<strong> <!--116--> </strong>\n<!--118-->\n<br><br>\n» [[Donate/Stories/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}|<!--117-->]]\n\n|live-comments=<strong> <!--50--></strong>\n<br><br>\n» [[Special:ContributionHistory/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}|<!--119-->]]\n\n|psa-text=<strong> <!--115 part 1--> </strong>\n<br><br>\n» [[PSAs|<!--115 part 2-->]]\n|image-lang={{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}\n}}\n{{2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]\n', editSummary: 'Thanks to translators from Meta: [[m:Fundraising 2008/core messages]]' },
		{ name: 'Questions', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-questions\n|page-title=Questions and Answers\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' },
		{ name: 'Benefactors', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-benefactors\n|page-title=Benefactors\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' },
		{ name: 'WaysToGive', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-waystogive\n|page-title=Ways To Give\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' },
		{ name: 'Chapters', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-chapters\n|page-title=Chapters\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' },
		{ name: 'Transparency', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-transparency\n|page-title=Transparency of the Wikimedia Foundation\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' },
		{ name: 'Stories', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-stories\n|page-title=Stories\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' },
		{ name: 'Thank You', template: '{{:Donate/Support/{{subst:SUBPAGENAME}}}}', editSummary: 'Create' },
		{ name: 'Chapters (Trans)', template: '{{Template:2008/Donate-header/{{subst:SUBPAGENAME}}}}\n{{Template:2008/Donate-chapters\n|page-title=Chapters\n|introduction=\n|campaign-header=\n|campaign=\n|ar=\n|ar-text=\n|au=\n|au-text=\n|at=\n|at-text=\n|br=\n|br-text=\n|cz=\n|cz-text=\n|fr=\n|fr-text=\n|de=\n|de-text=\n|hk=\n|hk-text=\n|hu=\n|hu-text=\n|id=\n|id-text=\n|il=\n|il-text=\n|it=\n|it-text=\n|nl=\n|nl-text=\n|pl=\n|pl-text=\n|ru=\n|ru-text=\n|rs=\n|rs-text=\n|se=\n|se-text=\n|ch=\n|ch-text=\n|tw=\n|tw-text=\n|uk=\n|uk-text=\n|other=\n|other-text=\n}}\n{{Template:2008/Donate-footer/{{subst:#titleparts:{{subst:FULLPAGENAME}}|1|-1}}}}\n[[Category:{{subst:#language:{{subst:SUBPAGENAME}}}}]]', editSummary: 'Create' }
	]);
});
// </nowiki>

/*************
*** Various from enwiki
*************/
function winc(s) {
	mw.loader.load('//en.wikipedia.org/w/index.php?title=' + s + '&action=raw&ctype=text/javascript');
}
winc('User:MarkS/extraeditbuttons.js'); // Script from [[User:MarkS/extraeditbuttons.js]] extra edit buttons
winc('User:Voice_of_All/replacetxt.js'); // Replace txt
winc('User:Voice_of_All/Google/monobook.js'); // Google tool
winc('User:Lupin/autoedit.js'); //Admin rollback tools
winc('User:Voice_of_All/Protection/monobook.js'); //Admin protection tools
winc('User:Voice_of_All/Deletion/monobook.js'); //Delete tabs
winc('User:Voice_of_All/Addtabs/monobook.js'); // Helper tools
winc('User:Voice of All/Specialadmin/monobook.js'); // More admin stuff

/*************
*** Override cross-site Ajax security, and reduce IE security settings
*************/
// For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ"
// Basically, enable "signed.applets.codebase_principal_support" in about:config
function makeRequestXML(url, parameters,type,parse) {
	if(window.XMLHttpRequest) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
		catch (e) {
			alert("Permission UniversalBrowserRead denied.");
		}
		http_request = false;
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
			http_request.overrideMimeType('text/xml');
		if (!http_request) {
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = alertContents;
		http_request.open(type, url + parameters, true);
		http_request.send(null);
	}
	else if (window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
		if (!http_request)
			showError(ERROR_XML);
		http_request.onreadystatechange = alertContents;
		http_request.open(type, url + parameters, true);
		http_request.send(null);
	}
}


/*************
*** customized confirm text; block anons only purge tab
*************/
$(function Dfn_js_con() {
	//moves
	Mvaluejs_class = 'yes';
	//edits
	Rvaluejs_class = 'yes';
	//uploads
	Uvaluejs_class = 'yes';
});

// Always check "block anons only" on Special:Blockip
$(function(){
	$('#wpAnonOnly').attr('checked', true);
	$('#wpCreateAccount').attr('checked', true);
	$('#wpEnableAutoblock').attr('checked', true);
});

// addPurge tab
$( function (){
	var x = document.getElementById('ca-history');
	if(!x) return;
	if(x.children) x = x.children[0].href;
	else x = x.childNodes[0].href;
	addLink("p-cactions", x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal cache for this page', 0);
});

/*************
*** "A bunch of stuff that starts with function"
*************/
// <nowiki>
function welcometn(num) {
	var varticle = '';
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	if (num==1) {
		t.value += "{{subst:Welcome}}. ~~~~";
		f.wpSummary.value = "Welcome to our free Encyclopedia!";
	}
	else if (num==2) {
		t.value += "{{subst:Anon}}. ~~~~";
		f.wpSummary.value = "Welcome to our free Encyclopedia!";
	}
	else if (num==3) {
		t.value += "{{subst:User:Centrx/Welcome}}";
		f.wpSummary.value = "Welcome to our free Encyclopedia!";
	}
}

function testn(number) {
	var IPnote = '';
	if (document.title.split(' - ')[0].split('.').length == 4) {
		IPnote = "''If this is an [[w:IP address|IP address]], and it is shared by multiple users, ignore this warning if you did not make any unconstructive edits.'' ";
	}
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value += "==" + "Regarding edits made during {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}}" + varticle + "==" + "\n" + "{{subst:" + "test" + number + "}} " + IPnote + "~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " test" + number;
}

function povn() {
	var IPnote = '';
	if (document.title.split(' - ')[0].split('.').length == 4) {
		IPnote = "''If this is an [[w:IP address|IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";
	}
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value += "==" + "Regarding edits made during {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}}" + varticle + "==" + "\n" + "{{subst:" + "NPOV0a" + "}} " + IPnote + "~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " NPOV0a";
}

function warningn() {
	var IPnote = '';
	if (document.title.split(' - ')[0].split('.').length == 4) {
		IPnote = "''If this is an [[w:IP address|IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";
	}
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="==" + "Regarding edits made during {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}}" + varticle + "==" + "\n" + "{{subst:" + "bv" + "}} " + IPnote + "~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " bv";
}

function revertsn() {
	var IPnoteR = '';
	if (document.title.split(' - ')[0].split('.').length == 4) {
		IPnoteR = "''If this is an [[w:IP address|IP address]], and it is shared by multiple users, ignore this warning, but aviod making any [[Wikipedia:revert|reverts]] within 24 hours of this warning in order to avoid any confusion.'' ";
	}
	var article = prompt("Enter the page name where the 3RR violation occured:");
	articleh = article.replace(/ /g, '_');
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="==" + "Regarding reversions" + "[http://en.wikipedia.org/w/index.php?title=" + articleh + "&action=history] " + "made on {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} to " + "[[" + article + "]]" + "==" + "\n" + "{{subst:" + "3rr" + "}} " + IPnoteR + "~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " 3rr";
}

function finalwn() {
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value += ":{{subst:" + "test4" + "}} ~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " final warning";
}

function blockn() {
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value += ":{{subst:" + "test5" + "}} ~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " temporary block";
}

function rrblockn() {
	username_a = document.URL.match(/:.*:(.*)/);
	username=username_a[1];
	var article = prompt("Enter the page name where the 3RR violation occured:");
	articleh = article.replace(/ /g, '_');
	var well = prompt("Warning is already in context (*y* or *n*)?");
	var time = prompt("Enter the duration of the block (in hours)");
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\r';
	t.value += '<div style="background-color: #f9f9f9; border: 1px solid red; padding: 3px;">' + '\n';
	if (well == 'y' || well == 'yes') {
		t.value += ":{{subst:" + "3rr3" + "}} The duration of the [http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username + " block] is " + time + " hours. [http://en.wikipedia.org/w/index.php?title=" + articleh + "&action=history Here] are the reverts in question. ~" + "~" + "~" + "~" + "</div>";
	}
	else if (well == 'n' || well == 'no') {
		t.value += "==" + "Regarding reversions" + "[http://en.wikipedia.org/w/index.php?title=" + articleh + "&action=history] " + "made on {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} to " + "[[" + article + "]]" + "==" + "\n" + "{{subst:" + "3rr3" + "}} The duration of the [http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username + " block] is " + time + " hours. ~" + "~" + "~" + "~" + "</div>";
	}
	else {
		prompt("Error, enter *y* or *n*.");
		return;
	}
	f.wpSummary.value = "User notice:" + " temporary 3RR block";
}

function testbl() {
	var IPnote = '';
	if (document.title.split(' - ')[0].split('.').length == 4) {
		IPnote = "''If this is an [[w:IP address|IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";
	}
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="==" + "Regarding edits made during {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}}" + varticle + "==" + "\n" + "{{subst:" + "test2a}} " + IPnote + "~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice:" + " test2a";
}

function spam(type) {
	if (type == 1)
		var temp = 'spam1';
	else if (type == 2)
		var temp = 'spam2a';
	var IPnote = '';
	if (document.title.split(' - ')[0].split('.').length == 4) {
		IPnote = "''If this is an [[w:IP address|IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";
	}
	var varticle = '';
	if (location.href.indexOf('&vanarticle=') != -1) {
		varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:')) + ']]';
	}
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="==" + "Regarding edits made during {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}}" + varticle + "==" + "\n" + "{{subst:" + temp + "}} " + IPnote + "~" + "~" + "~" + "~";
	f.wpSummary.value = "User notice: " + temp;
}

function rrwarn() {
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="*The user has now been warned per [[WP:3RR|3RR]] not to let this happen again. " + "~" + "~" + "~" + "~";
	t.value = t.value.replace(/\(Result:\)/,'(Result: user warned)');
	f.wpSummary.value = "Response: user warned";
}

function rrblock() {
	var number = prompt("User blocked for how many hours?");
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="*I have blocked the user for " + number + " hours per [[WP:3RR]]. " + "~" + "~" + "~" + "~";
	t.value = t.value.replace(/\(Result:\)/,'(Result: ' + number + ' hours)');
	f.wpSummary.value = "Response: user blocked";
}

function rrnoblock() {
	var f = document.editform, t = f.wpTextbox1;
	if (t.value.length > 0)
		t.value += '\n';
	t.value +="*The user has not yet violated [[WP:3RR]] because there are not yet four reverts within 24 hours nor is there any severely disruptive behavior. However, I have warned the user for nearly breaching [[WP:3RR]]. " + "~" + "~" + "~" + "~";
	t.value = t.value.replace(/\(Result:\)/,'(Result: no violation)');
	f.wpSummary.value = "Response: no violation";
}
// <nowiki>

/*************
*** Tab manipulation
*** from <http://commons.wikimedia.org/wiki/MediaWiki:Extra-tabs.js>
*************/
// <nowiki>
if (window.location.href.indexOf('action=edit') != -1 && window.location.href.indexOf('remexamplejpg=1') != -1) {
	$(function RemoveExampleJpg() {
		document.getElementById('wpSummary').value = "Removing [[Image:Example.jpg]], '''bold text''', etc...";
		var contents = document.getElementById('wpTextbox1').value;
		var newcontents = contents.replace(/(\[http:\/\/www\.example\.com link title\]|== Headline text ==|<math>Insert formula here<\/math>|<nowiki>Insert non-formatted text here<\/nowiki>|#REDIRECT \[\[Insert text\]\]|'''Bold text'''|''Italic text''|\[\[(Media:Example\.ogg|Image:Example\.jpg|Link title)\]\]|#REDIRECT \[\[Insert text\]\]|<s>Strike-through text<\/s>|<sup>Superscript text<\/sup>|<sub>Subscript text<\/sub>|<small>Small Text<\/small>|<!-- Comment -->|<gallery>\s+Image:Example.jpg\|Caption1\s+Image:Example.jpg\|Caption2\s+<\/gallery>|<blockquote>\s+Block quote\s+<\/blockquote>|\{\| class="wikitable"\s+\|-\s+! header 1\s+! header 2\s+! header 3\s+\|-\s+\| row 1, cell 1\s+\| row 1, cell 2\s+\| row 1, cell 3\s+\|-\s+\| row 2, cell 1\s+\| row 2, cell 2\s+\| row 2, cell 3\s+\|\})/g, "");
		document.getElementById('wpTextbox1').value = newcontents;
		document.getElementById('wpWatchthis').checked = "";
		document.getElementById('wpDiff').click();
	});
}

if(mw.config.get('wgCanonicalNamespace') != "Special") {
	$(function(){
		var taburl = "http://meta.wikimedia.org/w/index.php?title="+mw.config.get('wgPageName')+"&action=edit&remexamplejpg=1";
		addTab(taburl, "example.jpg", "ca-examplejpgfix", "This is to remove Image:Example.jpg from stuff");
	});
}
//</nowiki>

//more tabs
$(function add_testn_tabs() {
	var c1 = document.getElementById('column-one');
	var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
	if (document.title.indexOf("Talk:") == -1 && document.title.indexOf("talk:") == -1 && document.title.indexOf("User:") == -1 && document.title.indexOf("MediaWiki:") == -1 && document.title.indexOf("Image:") == -1 && document.title.indexOf("Wikipedia:") == -1 && document.title.indexOf("Template:") == -1 && document.title.indexOf("Portal:") == -1 && document.title.indexOf("Help:") == -1 && document.title.indexOf("Main Page") == -1 && document.title.indexOf("Category:") == -1) {
		if(document.getElementById('ca-edit'))
			document.getElementById('ca-edit').firstChild.innerHTML = 'Modify';
	}
	else {
		if(document.getElementById('ca-edit'))
			document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
		if(document.getElementById('ca-talk'))
			document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
	}
	if (document.title.indexOf("Editing ") != -1) {
		if (document.title.indexOf("Editing User talk:") != -1) {
			var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
			addlimenu(tabs, '{{message}}', 'warnfunc');
			var warnfunc = document.getElementById('warnfunc').getElementsByTagName('ul')[0];
			addlilink(warnfunc, 'javascript:welcometn(1)', 'welcome', '');
			addlilink(warnfunc, 'javascript:welcometn(3)', 'welcome2', '');
			addlilink(warnfunc, 'javascript:welcometn(2)', 'anon', '');
			addlilink(warnfunc, 'javascript:testn(1)', 'test', '');
			addlilink(warnfunc, 'javascript:povn()', 'NPOV', '');
			addlilink(warnfunc, 'javascript:testn(2)', 'vandal', '');
			addlilink(warnfunc, 'javascript:testn(3)', 'vandal2', '');
			addlilink(warnfunc, 'javascript:warningn()', 'warn', '');
			addlilink(warnfunc, 'javascript:testbl()', 'blanking', '');
			addlilink(warnfunc, 'javascript:spam(1)', 'spam', '');
			addlilink(warnfunc, 'javascript:spam(2)', 'spam2', '');
			addlilink(warnfunc, 'javascript:finalwn()', 'final', '');
			addlilink(warnfunc, 'javascript:blockn()', 'vblock', '');
			addlilink(warnfunc, 'javascript:revertsn()', '3rr', '');
			addlilink(warnfunc, 'javascript:rrblockn()', 'rr block', '');
			if(document.getElementById('ca-delete'))
				document.getElementById('ca-delete').firstChild.innerHTML = '<span style="color:red;">[d]</span>';
			if(document.getElementById('ca-move'))
				document.getElementById('ca-move').firstChild.innerHTML = '[m]';
			if(document.getElementById('ca-watch'))
				document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
			if(document.getElementById('ca-unwatch'))
				document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
			if(document.getElementById('ca-edit'))
				document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
		}
		else if (document.title.indexOf("Editing User:") != -1)
			var nothing = 'yes';
		else if (document.title.indexOf("Editing Wikipedia:Requests for page protection (section)") != -1) {
			if(document.getElementById('ca-delete'))
				document.getElementById('ca-delete').firstChild.innerHTML = '<span style="color:red;">[d]</span>';
			if(document.getElementById('ca-move'))
				document.getElementById('ca-move').firstChild.innerHTML = '[m]';
			if(document.getElementById('ca-watch'))
				document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
			if(document.getElementById('ca-unwatch'))
				document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
		}
		else if (document.title.indexOf("Editing Wikipedia:Administrators' noticeboard/3RR (section)") != -1) {
			addTab('javascript:rrwarn()',"a|wn","ca-wn","Warned","");
			addTab('javascript:rrblock()',"a|bl","ca-bl","Blocked","");
			addTab('javascript:rrnoblock()',"r|cl","ca-cl","Close to 3RR","");
		}
		else if(document.title.indexOf("Wikipedia:") != -1 || document.title.indexOf("Help:Contents/Editing Wikipedia") != -1 || document.title.indexOf("Editing Talk") != -1 || document.title.indexOf("Editing Wikipedia talk") != -1) {
			nothing=1;
		}
	}
	else if (document.title.indexOf("User:") != -1) {
		if(document.getElementById('ca-talk'))
			document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
	}
	else if (document.title.indexOf("User talk:") != -1) {
		if(document.getElementById('ca-talk'))
		document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
	}
});

//### 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 = name;
	li.appendChild(na);
	tabs.appendChild(li);
	return li;
}

//### 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;
}

// 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;
}

$(function formDefaults() {
	/* variables */
	var strFullUrl = location.href;
	var regFormEdit = /&action=(?:edit|submit)/;
	var regFormMove = /Special:Movepage/;
	var regFormDelete = /&action=delete/;
	var regFormUndelete = /Special:Undelete/;
	var regFormProtect = /&action=protect/;
	var regFormBlock = /Special:Blockip/;
	var regFormUnblock = /&action=unblock/;

	/* get current and fill */
	if(strFullUrl.match(regFormDelete)) {
		var objReason = fPageData('currentforminput');
		objReason.value = '[[WP:DENY|Unneeded userpage for an indefinitely blocked user]]';
		var watchbox = document.getElementById('wpWatch');
		watchbox.checked = true;
		objReason.focus();
	}
	else if(strFullUrl.match(regFormUnblock)) {
		var objReason = fPageData('currentforminput');
		objReason.value = 'Override [[Wikipedia:Autoblock|autoblock]]';
		objReason.focus();
	}
});

/*************
*** Other things
*************/
//mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/FilterRC.js&action=raw&ctype=text/javascript'); //Quick and dirty RC filtering script by pathos
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Splarka/portalpreview.js&action=raw&ctype=text/javascript');
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript');

mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/RTRC.js&action=raw&ctype=text/javascript');