User:MadeYourReadThis/mytwinkleext.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. |
![]() | Documentation for this user script can be added at User:MadeYourReadThis/mytwinkleext. |
// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
TwinkleConfig = {};
}
/**
TwinkleConfig.summaryAd (string)
If ad should be added or not to summary, default [[WP:TWINKLE|TWINKLE]]
*/
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
TwinkleConfig.summaryAd = " using [[WP:TW|TW]]";
}
/**
TwinkleConfig.watchProd2Pages (boolean)
If, when applying prod template to page, watch it, default true
*/
if( typeof( TwinkleConfig.watchProd2Pages ) == 'undefined' ) {
TwinkleConfig.watchProd2Pages = true;
}
function twinkleprod2() {
if( wgNamespaceNumber != 0 || wgCurRevisionId == false ) {
return;
}
if (twinkleConfigExists)
{
mw.util.addPortletLink( 'p-cactions', "javascript:twinkleprod2.callback()", "radioprod", "tw-radioprod", "Propose deletion of radio personality via WP:PROD", "");
}
else
{
mw.util.addPortletLink('p-cactions', 'javascript:alert("Your account is too new to use Twinkle.");', 'prod2', 'tw-prod2', 'Propose deletion via WP:PROD', '');
}
}
$(twinkleprod2);
twinkleprod2.callback = function twinkleprod2Callback() {
var Window = new SimpleWindow( 800, 400 );
Window.setTitle( "WP:PROD" );
var form = new QuickForm( twinkleprod2.callback.evaluate );
var field = form.append( {
type: 'field',
label: 'Reason for proposed deletion'
} );
field.append( {
type: 'textarea',
name: 'reason',
label: 'iReason:',
value: 'article fails to assert why this radio personality is notable. Lacks 3rd party verifiable references.'
} );
field.append( { type:'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
}
twinkleprod2.callbacks = {
main: function( self ) {
var form = self.responseXML.getElementById('editform');
var text = form.wpTextbox1.value;
var tag_re = /(\{\{(?:db-?|delete|[aitcmrs]fd|md1)[^{}]*?\|?[^{}]*?\}\})/;
if( tag_re.test( text ) ) {
self.statelem.warn( 'Page already tagged with a deletion template, aborting procedure' );
return;
}
// Notification to first contributor
var query = {
'action': 'query',
'prop': 'revisions',
'titles': wgPageName,
'rvlimit': 1,
'rvprop': 'user',
'rvdir': 'newer'
}
var postData = {
'wpMinoredit': undefined, // Per memo
'wpWatchthis': TwinkleConfig.watchProd2Pages ? '' : form.wpWatchthis.checked ? '' : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Proposing article for deletion per [[WP:PROD]]." + TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{subst:prod|1=" + self.params.reason + "}}\n" + text
};
self.post( postData );
}
}
twinkleprod2.callback.evaluate = function twinkleprod2CallbackEvaluate(e) {
var form = e.target;
var reason = form.reason.value;
wgPageName = wgPageName.replace(/_/g, ' ');
Status.init( form );
var query = {
'title': wgPageName,
'action': 'submit'
};
var wikipedia_wiki = new Wikipedia.wiki( 'Tagging page', query, twinkleprod2.callbacks.main );
wikipedia_wiki.params = { reason: reason };
wikipedia_wiki.followRedirect = false;
wikipedia_wiki.get();
}