User:Cometstyles/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.
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Cometstyles/fd.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js&action=raw&ctype=text/javascript');
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-blockoptions.js&action=raw&ctype=text/javascript');

/**
 * 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:'T1', template:'{{subst:test1|1=}}--~~~~', editSummary:'{{Test1}}'},
		{name:'T2', template:'{{subst:test2|1=}}--~~~~', editSummary:'{{Test2}}'},
		{name:'T3', template:'{{subst:test2|1=}}--~~~~', editSummary:'{{Test3}}'},
		{name:'delspam', template:'{{delete|spam}}--~~~~', editSummary:'{{spam}}'},
		{name:'delnon', template:'{{delete|nonsense}}--~~~~', editSummary:'{{nonsense}}'},
		{name:'Spam', template:'{{subst:spam|1=}}--~~~~', editSummary:'{{Spam}}'},
		{name:'Upload', template:'{{subst:upload warning}}--~~~~', editSummary:'{{uploadwarning}}'},
	]);
});
// </nowiki>

/**************
** [[User:Jsimlo/shortcuts.js]]
**************/
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Jsimlo/shortcuts.js&action=raw&ctype=text/javascript');
//function shortcutsInit() {
//	shortcutsAddLink ('Ipblocklist', 'Special:Ipblocklist');
//	shortcutsAddLink ('Rights', 'Special:UserRights');
//	shortcutsAddLink ('New pages', 'Special:Newpages');
//	shortcutsAddLink ('Links', 'special:linksearch');
//	shortcutsAddLink ('Prefix', 'Special:Prefixindex');
//	shortcutsAddLink ('Rename', 'Special:RenameUser');
//	shortcutsAddLink ('Shorts', 'Special:Shortpages');
//}

/**************
** Extra edit buttons
**************/
// Extra edit page buttons [[Wikipedia:Tools/Editing_tools#Misc._Editing_tools]]

// This is based on the original code on Wikipedia:Tools/Editing tools
//
// The original code was on the project page and needed to be cut and paste to the user's
// monobook.js page. However, this caused problems with the quote marks. So I have moved
// it to its own page.
//
// I do not know a lot about Javascript so please do not ask for a complicated change
//
// See the [[User:MarkS/Extra edit buttons]] for changes log

$(function addButtonsToToolbar() {
	d = new Date();
	todayISO = d.getFullYear()+"-";
	if (d.getMonth() > 8) {
		todayISO += (d.getMonth()+1)+"-";
	}
	else {
		todayISO += "0"+(d.getMonth()+1)+"-";
	}
	if (d.getDate() > 9) {
		todayISO += d.getDate();
	}
	else {
		todayISO += "0"+d.getDate();
	}

	if($.wikiEditor) {
		// <nowiki>
		$('#wpTextbox1').wikiEditor('addToToolbar', {
			section: 'main',
			group: 'format',
			tools: {
				//Strike-Out Button
				'custom-strike': {
					label: 'Strike',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<s>',
							post: '</s>'
						}
					}
				},

				//Table button
				'custom-table': {
					label: 'Table',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '\n{| border=\'1\' \n|- \n| 1 || 2\n|- \n| 3 || 4',
							post: '\n|}\n'
						}
					}
				},

				//Line break button
				'custom-linebreak': {
					label: 'Line break',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<br />',
							post: ''
						}
					}
				},

				//Gallery
				'custom-gallery': {
					label: 'Insert a picture gallery',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '\n<gallery>\n',
							post: '\n</gallery>'
						}
					}
				},

				//Category button
				'custom-category': {
					label: 'Category',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/5/5a/Button_category_alt.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '[[Category:',
							post: ']]'
						}
					}
				},

				//Reference link button
				'custom-ref': {
					label: '<ref>',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<ref>',
							post: '</ref>'
						}
					}
				},

				//Reference button
				'custom-reference-footer': {
					label: 'Reference footer',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '==References==\n{{reflist}}',
							post: ''
						}
					}
				},

				//ref+cite web
				'custom-cite-web': {
					label: 'Cite web',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/b/b8/Button_Globe.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<ref>{{cite web|url=',
							post: '|title=|publisher=|accessdate="+todayISO+"}}</ref>'
						}
					}
				},

				//redirect
				'custom-redirect': {
					label: 'Redirect',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '#REDIRECT [[',
							post: ']]'
						}
					}
				},

				//welcome
				'custom-welcome': {
					label: 'Welcome message',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/8/83/Button_biocitas.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '{{sub" + "st:welcome}}~~" + "~~',
							post: ''
						}
					}
				}
			}
		});
		// </nowiki>
	}
});

/**************
** Custom automatic delete buttons
**************/
// Adds customizable one-click deletion buttons to any deletable page.
// Requires w:User:Cometstyles/fd.js in appendScript();
var fdButtons = [];
fdButtons[fdButtons.length] = {
	'summary': '[[w:WP:NONSENSE|vandalism]]',
	'label': 'UN:N'
};

fdButtons[fdButtons.length] = {
	'summary': 'Test, please use the [[Project:Sandbox|sandbox]]',
	'label': 'test'
};
fdButtons[fdButtons.length] = {
	'summary': 'Please read about the [[WM:IP|Inclusion policy]]',
	'label': 'WM:IP'
};
fdButtons[fdButtons.length] = {
	'summary': 'Author/User Request',
	'label': 'req'
};
fdButtons[fdButtons.length] = {
	'summary': 'upload to [[commons:|commons]] with proper license and source',
	'label': 'com'
};
fdButtons[fdButtons.length] = {
	'summary': '[[commons:|Now Commons]]',
	'label': 'nc'
};

/**************
** Various
**************/
// [[User:Lupin/popups.js]]
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript');

// [[User:Invitatious/unsigned2.js]] - unsigned comments script (enwiki)
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Invitatious/unsigned2.js&action=raw&ctype=text/javascript');

// install [[User:Cacycle/diff]] text diff code
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Cacycle/diff.js&action=raw&ctype=text/javascript');

// install [[User:Cacycle/editor]] edit tool
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Cacycle/editor.js&action=raw&ctype=text/javascript');

importScript('User:Splarka/portalpreview.js');
mw.loader.load('//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-contribsrange.js&action=raw&ctype=text/javascript');