User:DangerousPanda/scripts/try.js

// // addPurge $(function {    var hist; var url;    if (!(hist = document.getElementById('ca-history') )) return;    if (!(url = hist.getElementsByTagName('a')[0] )) return;    if (!(url = url.href )) return;    mw.util.addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'), 'notify', 'ca-notify', 'notify somebody', '0'); });

bwnotifier.welcome = function welcomeUser { Status.init( document.getElementById('bodyContent') ); var params = { value: FriendlyConfig.quickWelcomeTemplate, article: QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '', mode: 'auto' };	var query = { 'title': wgPageName, 'action': 'submit' };	Wikipedia.actionCompleted.redirect = wgPageName; Wikipedia.actionCompleted.notice = "Welcoming complete, reloading talk page in some seconds"; var wikipedia_wiki = new Wikipedia.wiki( 'User talk page modification', query, bwnotifier.callbacks.main ); wikipedia_wiki.params = params; wikipedia_wiki.get; } bwnotifier.callback = function bwnotifierCallback( uid ) { var Window = new SimpleWindow( 600, 400 ); Window.setTitle( "Choose a notifier" ); var form = new QuickForm( bwnotifier.callback.evaluate, 'change' ); form.append( {			type: 'input',			name: 'article',			label: 'Linked article (if supported by template)',			value:( QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '' ),			tooltip: 'An article might be linked to the welcome if the template supports it. Leave empty for no artice to be linked. Templates that support a linked article are marked with an asterisk.  Ignored for templates that do not support a linked article.',			event: function( event ) {				event.stopPropagation;			}		}	); form.append( { type:'header', label:'noticeboards' } ); form.append( { type: 'radio', name: 'noticeboard', list: bwnotifier.standardList } ); var result = form.render; Window.setContent( result ); Window.display; } bwnotifier.standardList = [ {		label: ': ANI*', value: 'ANI' }, { 		label: ': WQA', value: 'WQA', ] // Set to true if template does not already have heading bwnotifier.headingHash = { 'ANI': false, 'WQA': false, } // Set to true if template already has signature bwnotifier.signatureHash = { 'ANI': false, 'WQA': false, } /* Set to true if template supports article * name from art template parameter */ bwnotifier.artHash = { 'ANI': true, 'WQA': true, } /* Set to true if template supports article * name from vanarticle template parameter */ bwnotifier.vandalHash = { 'ANI': false, 'WQA': false, } bwnotifier.callbacks = { main: function( self ) { var form = self.responseXML.getElementById( 'editform' ); // abort if mode is auto and form is not empty if( form.wpTextbox1.value != '\n' && self.params.mode == 'auto' ) { Status.info( 'Warning', 'User talk page not empty; aborting automatic welcome' ); Wikipedia.actionCompleted.event; return; }		var text = ''; Status.info( 'Info', 'Will add the notification to the '				+ ( FriendlyConfig.topWelcomes ? 'top' : 'bottom' )				+ ' of the user\'s talk page.' ); if( !FriendlyConfig.topWelcomes ) { text += form.wpTextbox1.value + '\n'; }		if( bwnotifier.headingHash[ self.params.value ] && FriendlyConfig.insertHeadings ) { Status.info( 'Info', 'Will create a new heading for the notification' ); text += FriendlyConfig.welcomeHeading + "\n"; }		Status.info( 'Info', 'Will substitute the notification' ); text += '\{\{subst:' + self.params.value; if( bwnotifier.artHash[ self.params.value ] ) { if( FriendlyConfig.insertUsername && self.params.value.substring(2,0) != 'W-' ) { Status.info( 'Info', 'Will add your username to the notification' ); text += '|' + wgUserName; }			if( self.params.article != '' ) { Status.info( 'Info', 'Will add article link to the notification' ); text += '|art=' + self.params.article; }		} else if( bwnotifier.vandalHash[ self.params.value ] ) { if( self.params.article != '' ) { Status.info( 'Info', 'Will add vandalized article link to the notification' ); }			text += '|' + self.params.article; if( FriendlyConfig.insertUsername ) { Status.info( 'Info', 'Will add your username to the template' ); text += '|' + wgUserName; }		} else if( FriendlyConfig.insertUsername ) { Status.info( 'Info', 'Will add your username to the notification' ); text += '|' + wgUserName; } 		text += '\}\}'; if( !bwnotifier.signatureHash[ self.params.value ] && FriendlyConfig.insertSignature ) { Status.info( 'Info', 'Will add your signature after the notification' ); text += ' \n\~\~\~\~'; }		if( FriendlyConfig.topWelcomes ) { text += '\n\n' + form.wpTextbox1.value; }		var postData = { 'wpMinoredit': FriendlyConfig.markWelcomesAsMinor ? 1 : undefined, 'wpWatchthis': form.wpWatchthis.checked ? 1 : (FriendlyConfig.watchWelcomes ? 1 : undefined), 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': 'Added ' + ( FriendlyConfig.maskTemplateInSummary ? 'welcome' : ( '\{\{' + self.params.value + '\}\}' ) ) + ' template to user talk page' + FriendlyConfig.summaryAd, 'wpTextbox1': text };		self.post( postData ); } }

//