text:
User:Flewis/twinklespeedy.js

// If TwinkleConfig aint exist. if( typeof( TwinkleConfig ) == 'undefined' ) { TwinkleConfig = {}; }

/** TwinkleConfig.summaryAd (string)en.wikipedia.org If ad should be added or not to summary, default TWINKLE */ if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) { TwinkleConfig.summaryAd = " using TW"; }

/** TwinkleConfig.deletionSummaryAd (string) If ad should be added or not to deletion summary, default TWINKLE */ if( typeof( TwinkleConfig.deletionSummaryAd ) == 'undefined' ) { TwinkleConfig.deletionSummaryAd = " using TW"; }

/** TwinkleConfig.watchSpeedyPages (array) What types of actions that should result in forced addition to watchlist */ if( typeof( TwinkleConfig.watchSpeedyPages ) == 'undefined' ) { TwinkleConfig.watchSpeedyPages = [ 'g3', 'g5', 'g10', 'g11', 'g12' ]; }

/** TwinkleConfig.markSpeedyPagesAsMinor (boolean) If, when applying speedy template to page, to mark the edit as minor, default true */ if( typeof( TwinkleConfig.markSpeedyPagesAsMinor ) == 'undefined' ) { TwinkleConfig.markSpeedyPagesAsMinor = true; }

/** TwinkleConfig.notifyUserOnSpeedyDeletionNomination (array) What types of actions that should result that the author of the page should be notified of nomination */ if( typeof( TwinkleConfig.notifyUserOnSpeedyDeletionNomination ) == 'undefined' ) { TwinkleConfig.notifyUserOnSpeedyDeletionNomination = [ 'g1', 'g2', 'g3', 'g4', 'g10', 'g11', 'g12', 'a1', 'a2', 'a3', 'a5', 'a7', 'i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7', 'i8', 'i9', 'u3', 't1', 't2', 't3', 'p2' ]; }

/** TwinkleConfig.userTalkPageMode may take arguments: 'window': open a new window, remmenber the opened window 'tab': opens in a new tab, if possible. 'blank': force open in a new window, even if a such window exist */ if( typeof( TwinkleConfig.userTalkPageMode ) == 'undefined' ) { TwinkleConfig.userTalkPageMode = 'window'; }

/** TwinkleConfig.deleteTalkPageOnDelete If talk page if exists should also be deleted (CSD G8) when spedying a page (admin only) */ if( typeof( TwinkleConfig.deleteTalkPageOnDelete ) == 'undefined' ) { TwinkleConfig.deleteTalkPageOnDelete = false; }

/** TwinkleConfig.toolboxButtons (string) If id defined in this array, the button of the action is located inthe toolbox instead of in the actions bar. */ if( typeof( TwinkleConfig.toolboxButtons ) == 'undefined' ) { TwinkleConfig.toolboxButtons = []; }

/** TwinkleConfig.orphanNormalPagesOnSpeedyDelete (hash) Defines if all backlinks to a page should be removed. property 'exclude' defined actions not to orphan */ if( typeof( TwinkleConfig.orphanBacklinksOnSpeedyDelete ) == 'undefined' ) { TwinkleConfig.orphanBacklinksOnSpeedyDelete = { exclude: ['g6'], orphan:true }; }

function twinklespeedy { if( wgNamespaceNumber < 0 || wgCurRevisionId == false ) { return; }	if( userIsInGroup( 'sysop' ) ) { mw.util.addPortletLink( 'p-cactions', "javascript:twinklespeedy.callback", "csd", "tw-csd", "Speedy delete according to WP:CSD", ""); } else if (twinkleConfigExists) { mw.util.addPortletLink( 'p-cactions', "javascript:twinklespeedy.callback", "csd", "tw-csd", "Request speedy deletion according to WP:CSD", ""); }	else {		mw.util.addPortletLink('p-cactions', 'javascript:alert("Your account is too new to use Twinkle.");', 'csd', 'tw-csd', 'Request speedy deletion according to WP:CSD', ''); } } $(twinklespeedy);

twinklespeedy.callback = function twinklespeedyCallback { var Window = new SimpleWindow( 800, 400 ); Window.setTitle( "Choose criteria for speedy deletion" );

var form = new QuickForm( userIsInGroup( 'sysop' ) ? twinklespeedy.callback.evaluateSysop : twinklespeedy.callback.evaluateUser, 'change' ); if( userIsInGroup( 'sysop' ) ) { form.append( {				type: 'checkbox',				list: [					{						label: 'Tag page only, don\'t delete',						value: 'tag_only',						name: 'tag_only',						tooltip: 'If you just want to tag the page, instead of deleting it now',						event: function( event ) {							event.target.form.notify.disabled = ! event.target.checked;							event.stopPropagation;						}					},					{						label: 'Orphan backlinks',						value: 'orphan_backlinks',						name: 'orphan_backlinks',						tooltip: 'If you want to orphan all backlinks to current page, if checked, excludes will still apply',						checked: TwinkleConfig.orphanBacklinksOnSpeedyDelete.orphan,						event: function( event ) {							TwinkleConfig.orphanBacklinksOnSpeedyDelete.orphan = event.target.checked;							event.stopPropagation;						}					}				]			} ); }

form.append( {			type: 'checkbox',			list: [				{					label: 'Notify if possible',					value: 'notify',					name: 'notify',					tooltip: 'If a notification if defined in the configuration, then notify if this is true, else no notify',					checked: true,					disabled: userIsInGroup( 'sysop' ),					event: function( event ) {						event.stopPropagation;					}				}			]		}	); if( wgNamespaceNumber == Namespace.IMAGE ) { form.append( {type:'header', label:'Images/Media' } ); form.append ( {				type: 'radio',				name: 'csd',				list: [					{ 						label: 'I1: Redundant image',						value: 'redundantimage',						tooltip: 'Any image that is a redundant copy, in the same image file format and same or lower resolution, of something else on Wikipedia. Likewise, other media that is a redundant copy, in the same format and of the same or lower quality. This does not apply to images duplicated on Wikimedia Commons, because of licence issues; these should be tagged with \{\{subst:ncd|Image:newname.ext\}\} or \{\{subst:ncd\}\} instead' 					},					{ 						label: 'I2: Corrupt or empty image',						value: 'noimage', 						tooltip: 'Before deleting this type of image, verify that the MediaWiki engine cannot read it by previewing a resized thumbnail of it. This also includes empty (i.e., no content) image description pages for Commons images' 					},					{ 						label: 'I3: Improper license', value: 'noncom', tooltip: '"Images licensed as "for non-commercial use only", "non-derivative use" or "used with permission" that were uploaded on or after 2005-05-19, except where they have been shown to comply with the limited standards for the use of non-free content. This includes images licensed under a "Non-commercial Creative Commons License". Such images uploaded before 2005-05-19 may also be speedily deleted if they are not used in any articles'					},					{						label: 'I4: Lack of licensing information', 						value: 'unksource',						tooltip: 'Images in category "Images with unknown source", "Images with unknown copyright status", or "Images with no copyright tag" that have been tagged with a template that places them in the category for more than seven days, regardless of when uploaded. Note, users sometimes specify their source in the upload summary, so be sure to check the circumstances of the image' },					{						label: 'I5: Unused unfree copyrighted images', value: 'unfree', tooltip: 'Images and other media that are not under a free license or in the public domain that are not used in any article and that have been tagged with a template that places them in a dated subcategory of Category:Orphaned fairuse images for more than seven days. Reasonable exceptions may be made for images uploaded for an upcoming article. Use \{\{subst:orfud\}\} to tag images for forthcoming deletion' },					{						label: 'I6: Missing fair-use rationale', value: 'norat', tooltip: 'Any image or media without a fair use rationale may be deleted seven days after it is uploaded. Boilerplate fair use templates do not constitute a fair use rationale. Images and other media uploaded before 2006-05-04 should not be deleted immediately; instead, the uploader should be notified that a fair-use rationale is needed. Images or other media uploaded after 2006-05-04 can be tagged with \{\{subst:nrd\}\}, and the uploader notified with \{\{subst:missing rationale|Image:image name\}\}. Such images can be found in the dated subcategories of Category:Images with no fair use rationale' },					{ 						label: 'I7: Invalid fair-use claim', value: 'badfairuse', tooltip: 'Any image or media with a clearly invalid fair-use tag (such as a \{\{logo\}\} tag on a photograph of a mascot) may be deleted at any time. Media that fail any part of the non-free content criteria and were uploaded after 2006-07-13 may be deleted forty-eight hours after notification of the uploader. For media uploaded before 2006-07-13 or tagged with the \{\{Replaceable fair use\}\} template, the uploader will be given seven days to comply with this policy after being notified' },					{						label: 'I8: Images available as bit-for-bit identical copies on the Wikimedia Commons', value: 'nowcommons', tooltip: 'Provided the following conditions are met: 1: The image\'s license and source status is beyond reasonable doubt, and the license is undoubtedly accepted at Commons. 2: All information on the image description page is present on the Commons image description page. That includes the complete upload history with links to the uploader\'s local user pages. 3: The image is not protected, and the image description page does not contain a request not to move it to Commons. 4: The image has been marked with Template:NowCommons for at least one week. Waiting one week is not necessary if it was the uploader who moved the image and marked it. 5: If the image is available on Commons under a different name than locally, all local references to the image must be updated to point to the title used at Commons. 6: For \{\{c-uploaded\}\} images: They may be speedily deleted as soon as they are off the Main Page' },					{						label: 'I9: Blatant copyright infringement', value: 'imgcopyvio', tooltip: 'The image was copied from a website or other source that does not have a license compatible with Wikipedia, and the uploader does not assert that it is public domain, freely licensed, fair use, or used with permission. Sources that do not have a license compatible with Wikipedia include stock photo libraries such as Getty Images or Corbis. Non-blatant copyright infringements should be discussed at Wikipedia:Images and media for deletion' },					{						label: 'I10: Useless media file', value: 'badfiletype', tooltip: 'Files uploaded that are neither image, sound, nor video files (e.g. .doc, .pdf, or .xls files) which are not used in any article and have no foreseeable encyclopedic use' }				]			} );	}

form.append( { type:'header', label:'General criteria' } ); form.append( {			type: 'radio',			name: 'csd',			list: [				{ 					label: 'G1: Nonsense', 					value: 'nonsense', 					tooltip: 'Patent nonsense and gibberish, an unsalvageably incoherent page with no meaningful content. This does not include: poor writing, partisan screeds, obscene remarks, vandalism, fictional material, material not in English, badly translated material, implausible theories, or hoaxes' },				{ 					label: 'G2: Test page',					value: 'test',					tooltip: 'e.g., "Can I really create a page here?"' 				},				{ 					label: 'G3: Pure vandalism',					value: 'vandalism',					tooltip: 'Plain pure vandalism'				},				{ 					label: 'G3: Pagemove', 					value: 'pagemove',					tooltip: 'Nonsense redirects that are created from the cleanup of page move vandalism'				},				{					label: 'G4: Recreation of deleted material',					value: 'repost',					tooltip: 'A copy, by any title, of a page that was deleted via an XfD process or Deletion review, provided that the copy is substantially identical to the deleted version and that any revisions made clearly do not address the reasons for which the page was deleted. This clause does not apply to content that has been "userfied", to content undeleted as a result of Deletion review, or if the prior deletions were proposed or speedy deletions, although in this last case, the previous speedy criterion, or other speedy deletion criteria, may apply' },				{					label: 'G5: Banned user', value: 'banned', tooltip: 'Pages created by banned users while they were banned' },				{					label: 'G6: History merge', value: 'histmerge', tooltip: 'Temporarily deleting a page in order to merge page histories' },				{					label: 'G6: Move', value: 'move', tooltip: 'Making way for a noncontroversial move like reversing a redirect' },				{					label: 'G6: Afd', value: 'afd', tooltip: 'An admin has closed an Articles for deletion debate as a "delete"' },				{					label: 'G6: Housekeeping', value: 'g6', tooltip: 'Other non-controversial "housekeeping" tasks' },				{					label: 'G7: Author requests deletion', value: 'author', tooltip: 'Any page for which deletion is requested by the original author in good faith, provided the page\'s only substantial content was added by its author' },				{					label: 'G7: Author blanked', value: 'blanked', tooltip: ' If the author blanks the page, this can be taken as a deletion request' },				{					label: 'G8: Talk pages whose corresponding article does not exist', value: 'talk', tooltip: 'unless: It contains deletion discussion that is not logged elsewhere; It is a User Talk page; It is the Talk page for an image uploaded on the Wikimedia Commons; It is a Talk subpage (such as archived Talk pages) whose corresponding top-level article does exist' },				{ 					label: 'G10: Attack page', value: 'attack', tooltip: 'Pages that serve no purpose but to disparage their subject or some other entity (e.g., "John Q. Doe is an imbecile"). This includes a biography of a living person that is negative in tone and unsourced, where there is no NPOV version in the history to revert to. Administrators deleting such pages should not quote the content of the page in the deletion summary!' },				{ 					label: 'G11: Blatant advertising', value: 'spam', tooltip: 'Pages which exclusively promote a company, product, group, service, or person and which would need to be fundamentally rewritten in order to become encyclopedic. Note that simply having a company, product, group, service, or person as its subject does not qualify an article for this criterion; an article that is blatant advertising should have inappropriate content as well' },				{ 					label: 'G12: Blatant copyright infringement', value: 'copyvio', tooltip: 'Either, 1: Material was copied from another website that does not have a license compatible with Wikipedia, or is photography from a stock photo seller (such as Getty Images or Corbis) or other commercial content provider; 2: There is no non-infringing content in the page history worth saving; or 3: The infringement was introduced at once by a single person rather than created organically on wiki and then copied by another website such as one of the many Wikipedia mirrors' }			]		}); if( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) {	form.append( { type:'header', label:'Articles' } );	form.append( { type: 'radio', name: 'csd', list: [ {					label: 'A1: Little or no context', value: 'nocontext', tooltip: 'Very short articles providing little or no context (e.g., "He is a funny man that has created Factory and the Hacienda. And, by the way, his wife is great."). Limited content is not in itself a reason to delete if there is enough context for the article to qualify as a valid stub' },				{					label: 'A2: Foreign language articles that exist on another Wikimedia project', value: 'foreign', tooltip: 'If the article in question does not exist on another project, the template \{\{notenglish\}\} should be used instead. All articles in a non-English language that do not meet this criteria (and do not meet any other criteria for speedy deletion) should be listed at Pages Needing Translation (PNT) for review and possible translation' },				{					label: 'A3: No content whatsoever', value: 'nocontent', tooltip: 'Any article consisting only of links elsewhere (including hyperlinks, category tags and "see also" sections), a rephrasing of the title, and/or attempts to correspond with the person or group named by its title. This does not include disambiguation pages' },				{					label: 'A5: Transwikied articles', value: 'transwiki', tooltip: 'Any article that has been discussed at Articles for Deletion (et al), where the outcome was to transwiki, and where the transwikification has been properly performed and the author information recorded. Alternately, any article that consists of only a dictionary definition, where the transwikification has been properly performed and the author information recorded' },				{					label: 'A7: Unremarkable people, groups, companies and web content', value: 'notability', tooltip: 'An article about a real person, group of people, band, club, company, or web content that does not assert the importance or significance of its subject. If controversial, or if there has been a previous AfD that resulted in the article being kept, the article should be nominated for AfD instead' },				{					label: 'A7: Unremarkable band', value: 'band', tooltip: 'Article about a band, singer, musician, or musical ensemble that does not assert the importance or significance of the subject' },				{					label: 'A7: Unremarkable club', value: 'club', tooltip: 'Article about a club that does not assert the importance or significance of the subject' },				{					label: 'A7: Unremarkable company', value: 'inc', tooltip: 'Article about a company or corporation that does not assert the importance or significance of the subject' },				{					label: 'A7: Unremarkable website', value: 'web', tooltip: 'Article about a web site, blog, online forum, webcomic, podcast, or similar web content that does not assert the importance or significance of its subject' }			]		} ); }	form.append( { type:'header', label: 'Redirects' } );	form.append( { type: 'radio', name: 'csd', list: [ { 					label: 'R1: Redirects to nonexistent pages', value: 'redirnone' },				{ 					label: 'R2: Redirects to the Talk:, User: or User talk: namespace from the article space', value: 'rediruser', tooltip: '(this does not include the Wikipedia shortcut pseudo-namespaces). If this was the result of a page move, consider waiting a day or two before deleting the redirect' },				{ 					label: 'R3: Redirects as a result of an implausible typo that were recently created', value: 'redirtypo', tooltip: 'However, redirects from common misspellings or misnomers are generally useful, as are redirects in other languages' }			]		} ); if( wgNamespaceNumber == 14 || wgNamespaceNumber == 15 ) {	form.append( { type:'header', label: 'Categories' } );	form.append( { type: 'radio', name: 'csd', list: [ { 					label: 'C1: Empty categories', value: 'catempty', tooltip: '(no articles or subcategories for at least four days) whose only content has consisted of links to parent categories. This does not apply to categories being discussed on WP:CFD or WP:SFD, or disambiguation categories. If the category isn\'t relatively new, it possibly contained articles earlier, and deeper investigation is needed' },				{					label: 'C3: Template categories', value: 'catfd', tooltip: 'If a category is solely populated from a template (e.g. Category:Wikipedia cleanup from \{\{cleanup\}\}) and the template is deleted per deletion policy, the category can also be deleted without further discussion' }			]		} ); } if( wgNamespaceNumber == 2 || wgNamespaceNumber == 3 ) {	form.append( { type:'header', label: 'User pages' } );	form.append( { type: 'radio', name: 'csd', list: [ {					label: 'U1: User request', value: 'userreq', tooltip: 'Personal subpages, upon request by their user. In some rare cases there may be administrative need to retain the page. Also, sometimes, main user pages may be deleted as well. See Wikipedia:User page for full instructions and guidelines' },				{					label: 'U2: Nonexistent user', value: 'nouser', tooltip: 'User pages of users that do not exist (Check Special:Listusers)' },				{					label: 'U3: Non-free galleries', value: 'gallery', tooltip: 'Galleries in the userspace which consist mostly of "fair use" or non-free images. Wikipedia\'s non-free content policy forbids users from displaying non-free images, even ones they have uploaded themselves, in userspace. It is acceptable to have free images, GFDL-images, Creative Commons and similar licenses along with public domain material, but not "fair use" images' },			]		} ); } if( wgNamespaceNumber == 10 || wgNamespaceNumber == 11 ) {	form.append( { type:'header', label: 'Templates' } );	form.append( { type: 'radio', name: 'csd', list: [

{ 					label: 'T1: Templates that are divisive and inflammatory', value: 'divisive' },				{					label: 'T2: Templates that are blatant misrepresentations of established policy', value: 'policy', tooltip: 'This includes "speedy deletion" templates for issues that are not speedy deletion criteria and disclaimer templates intended to be used in articles' },				{					label: 'T3: Templates that are not employed in any useful fashion', value: 't3', tooltip: 'Templates that are either substantial duplications of another template or hardcoded instances of another template where the same functionality could be provided by that other template' }			]		} ); } if( wgNamespaceNumber == 100 || wgNamespaceNumber == 101 ) {	form.append( { type:'header', label: 'Portals' } );	form.append( { type: 'radio', name: 'csd', list: [ {					label: 'P2: Underpopulated portal', value: 'emptyportal', tooltip: 'Any Portal based on a topic for which there is not a non-stub header article, and at least three non-stub articles detailing subject matter that would be appropriate to discuss under the title of that Portal' }			]		} ); }

var result = form.render; Window.setContent( result ); Window.display; }

twinklespeedy.normalizeHash = { 'nonsense': 'g1', 'test': 'g2', 'vandalism': 'g3', 'pagemove': 'g3', 'repost': 'g4', 'banned': 'g5', 'histmerge': 'g6', 'move': 'g6', 'afd': 'g6', 'g6': 'g6', 'author': 'g7', 'blanked': 'g7', 'talk': 'g8', 'attack': 'g10', 'spam': 'g11', 'copyvio': 'g12', 'nocontext': 'a1', 'foreign': 'a2', 'nocontent': 'a3', 'transwiki': 'a5', 'bio': 'a7', 'inc': 'a7', 'web': 'a7', 'band': 'a7', 'club': 'a7', 'redirnone': 'r1', 'rediruser': 'r2', 'redirtypo': 'r3', 'redundantimage': 'i1', 'noimage': 'i2', 'noncom': 'i3', 'unksource': 'i4', 'unfree': 'i5', 'norat': 'i6', 'badfairuse': 'i7', 'nowcommons': 'i8', 'imgcopyvio': 'i9', 'badfiletype': 'i10', 'catempty': 'c1', 'catfd': 'c3', 'userreq': 'u1', 'nouser': 'u2', 'gallery': 'u3', 'divisive': 't1', 'policy':'t2', 't3':'t3', 'emptyportal': 'p2' };

twinklespeedy.reasonHash = { 'nonsense': 'was patent nonsense: an unsalvageably incoherent page with no meaningful content', 'test': 'was a test page', 'vandalism': 'was pure vandalism', 'pagemove': 'was a redirect created during cleanup of page move vandalism', 'repost': 'was a copy of material previously deleted per XfD', 'banned': 'was a contribution was made by a banned user', 'histmerge': 'temporary deletion in order to merge page histories', 'move': 'making way for a non-controversial move', 'afd': 'deleting page per result of AfD discussion', 'g6': 'non-controversial housekeeping deletion', 'author': 'only editor requested deletion', 'blanked': 'only editor has blanked the page', 'talk': 'was a talk page whose corresponding page does not exist', 'attack': 'was a attack page intented to disparage its subject', 'spam': 'was blatant advertising, used only to promote someone or something', 'copyvio': 'was a blatant copyright infringement', 'nocontext': 'was a very short article providing little or no context', 'foreign': 'was a foreign language article that exists on another Wikimedia project', 'nocontent': 'had no content whatsoever except possibly links elsewhere, a rephrasing of the title, and/or attempts to correspond', 'transwiki': 'was properly transwikified elsewhere', 'bio': 'was an article about a real person, group of people, band, club, company, or web content that didn\'t assert the importance or significance of its subject', 'web': 'was an article about a web site, blog, online forum, webcomic, podcast, or similar web content that didn\'t assert the importance or significance of its subject', 'inc': 'was an article about a company or corporation that didn\'t assert the importance or significance of its subject', 'club': 'was an article about a club that didn\'t assert the importance or significance of the subject', 'band': 'was an article about a band, singer, musician, or musical ensemble that didn\'t assert the importance or significance of the subject', 'redirnone': 'was a redirect to an non-existent page', 'rediruser': 'was a redirect to the Talk:, User: or User talk: space', 'redirtypo': 'was a redirect based on an implausible typo', 'redundantimage': 'a same or better image exists on Wikipedia', 'noimage': 'was a corrupt or empty image', 'noncom': 'was licensed as "for non-commercial use only", "non-derivative use" or "used with permission", uploaded on or after May 19, 2005, and no assertion of fair use was provided', 'unksource': 'was an image lacking sources or licensing information for more than seven days', 'unfree': 'was an unfree image unused for more than seven days', 'norat': 'was an image with fair use tag but no fair use rationale for more than seven days', 'badfairuse': 'was an image with an invalid fair use rationale and the uploader was notified more than 48 hours ago', 'nowcommons': 'was an image available as a bit-for-bit identical copy on the Wikimedia Commons', 'imgcopyvio': 'was an image that was a suspected copyright infringement, and the uploader didn\'t assert public domain, fair use, or a free license', 'badfiletype':'was an file that was not an image, video, nor sound, was unused, and had no foreseeable encyclopedic use', 'catempty': 'was an empty category for at least four days', 'catfd': 'was a category solely populated from a now deleted template', 'userreq': 'was a user page whose user requested deletion', 'nouser': 'was a user page of a user that did not exist', 'gallery': 'was a gallery in the user space which consisted mostly of fair use images', 'divisive': 'was an divisive and inflammatory template', 'policy': 'was an template that was a blatant misrepresentation of established policy', 't3': 'was a template which was a duplicate of, hard-coded instance of, or an inferior alternative to a other template', 'emptyportal': 'was an underpopulated portal' };

twinklespeedy.callbacks = { sysop: { main: function( self ) { var xmlDoc = self.responseXML; var normal = xmlDoc.evaluate( '//normalized/n/@to', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue; if( normal ) { wgPageName = normal; }			var exists = xmlDoc.evaluate( 'boolean(//pages/page[not(@missing)])', xmlDoc, null, XPathResult.BOOLEAN_TYPE, null ).booleanValue;

if( ! exists ) { self.statelem.error( "It seems that the page doesn't exists, perhaps it has already been deleted" ); return; }			var query = { 'title': wgPageName, 'action': 'delete' };

var wikipedia_wiki = new Wikipedia.wiki( 'Deleting page', query, twinklespeedy.callbacks.sysop.deletePage ); wikipedia_wiki.params = self.params; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get;

if( 				TwinkleConfig.deleteTalkPageOnDelete && 				self.params.normalized != 'i8' &&				wgNamespaceNumber % 2 == 0 && 				document.getElementById( 'ca-talk' ).className != 'new' 			) { var talk_page = namespaces[ wgNamespaceNumber + 1 ] + ':' + wgTitle; var query = query = { 'title': talk_page, 'action': 'delete' };				var wikipedia_wiki = new Wikipedia.wiki( 'Deleting talk page', query, twinklespeedy.callbacks.sysop.deleteTalkPage ); wikipedia_wiki.params = self.params; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get; }

if( wgNamespaceNumber == 6 && self.params.normalized != 'i8' ) { var query = { 'action': 'query', 'list': 'imageusage', 'titles': wgPageName, 'iulimit': userIsInGroup( 'sysop' ) ? 5000 : 500 // 500 is max for normal users, 5000 for bots and sysops };				var wikipedia_api = new Wikipedia.api( 'Grabbing image links', query, twinklespeedy.callbacks.sysop.unlinkImageInstancesMain ); wikipedia_api.params = self.params; wikipedia_api.post; }			var doOrphan = TwinkleConfig.orphanBacklinksOnSpeedyDelete; if( 				doOrphan.orphan && 				doOrphan.exclude.indexOf( self.params.normalized.toLowerCase ) == -1 			) { var query = { 'action': 'query', 'list': 'backlinks', 'blfilterredir': 'nonredirects', 'bltitle': wgPageName, 'bllimit': userIsInGroup( 'sysop' ) ? 5000 : 500, // 500 is max for normal users, 5000 for bots and sysops 'blnamespace': [0, 100] // Main namespace and portal namespace only, keep on talk pages. };				var wikipedia_api = new Wikipedia.api( 'Grabbing backlinks', query, twinklespeedy.callbacks.sysop.unlinkBacklinksMain ); wikipedia_api.params = self.params; wikipedia_api.post; }			var query = { 'action': 'query', 'list': 'backlinks', 'blfilterredir': 'redirects', 'bltitle': wgPageName, 'bllimit': userIsInGroup( 'sysop' ) ? 5000 : 500 // 500 is max for normal users, 5000 for bots and sysops };			var wikipedia_api = new Wikipedia.api( 'Grabbing redirects', query, twinklespeedy.callbacks.sysop.deleteRedirectsMain ); wikipedia_api.params = self.params; wikipedia_api.post;

},		unlinkBacklinksMain: function( self ) { var xmlDoc = self.responseXML; var snapshot = xmlDoc.evaluate('//backlinks/bl/@title', xmlDoc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

if( snapshot.snapshotLength == 0 ) { return; }

var statusIndicator = new Status('Removing backlinks', '0%');

var total = snapshot.snapshotLength * 2;

var onsuccess = function( self ) { var obj = self.params.obj; var total = self.params.total; var now = parseInt( 100 * ++(self.params.current)/total ) + '%'; obj.update( now ); self.statelem.unlink; if( self.params.current >= total ) { obj.info( now + ' (completed)' ); Wikipedia.removeCheckpoint; }			}			var onloaded = onsuccess;

var onloading = function( self ) {}

Wikipedia.addCheckpoint; if( snapshot.snapshotLength == 0 ) { statusIndicator.info( '100% (completed)' ); Wikipedia.removeCheckpoint; return; }

var params = clone( self.params ); params.current = 0; params.total = total; params.obj = statusIndicator; params.page = wgPageName;

for ( var i = 0; i < snapshot.snapshotLength; ++i ) { var title = snapshot.snapshotItem(i).value; var query = { 'title': title, 'action': 'submit' }				var wikipedia_wiki = new Wikipedia.wiki( "Unlinking on " + title, query, twinklespeedy.callbacks.sysop.unlinkBacklinks ); wikipedia_wiki.params = params; wikipedia_wiki.onloading = onloading; wikipedia_wiki.onloaded = onloaded; wikipedia_wiki.onsuccess = onsuccess; wikipedia_wiki.get; }		},		unlinkBacklinks: function( self ) { var form = self.responseXML.getElementById('editform'); var text = form.wpTextbox1.value; var old_text = text; var wikiPage = new Mediawiki.Page( text ); wikiPage.removeLink( self.params.page );

text = wikiPage.getText; if( text == old_text ) { // Nothing to do, return self.onsuccess( self ); Wikipedia.actionCompleted( self ); return; }			var postData = { 'wpMinoredit': form.wpMinoredit.checked ? '' : undefined, 'wpWatchthis': undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': 'Removing backlinks to ' + self.params.page + " that has been speedily deleted per (CSD " + self.params.normalized.toUpperCase + ")" + "; " + TwinkleConfig.deletionSummaryAd, 'wpTextbox1': text };			self.post( postData ); },		deleteRedirectsMain: function( self ) { var xmlDoc = self.responseXML; var snapshot = xmlDoc.evaluate('//backlinks/bl/@title', xmlDoc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

var total = snapshot.snapshotLength * 2;

if( snapshot.snapshotLength == 0 ) { return; }

var statusIndicator = new Status('Deleting redirects', '0%');

var onsuccess = function( self ) { var obj = self.params.obj; var total = self.params.total; var now = parseInt( 100 * ++(self.params.current)/total ) + '%'; obj.update( now ); self.statelem.unlink; if( self.params.current >= total ) { obj.info( now + ' (completed)' ); Wikipedia.removeCheckpoint; }			}			var onloaded = onsuccess;

var onloading = function( self ) {}

Wikipedia.addCheckpoint; if( snapshot.snapshotLength == 0 ) { statusIndicator.info( '100% (completed)' ); Wikipedia.removeCheckpoint; return; }

var params = clone( self.params ); params.current = 0; params.total = total; params.obj = statusIndicator;

for ( var i = 0; i < snapshot.snapshotLength; ++i ) { var title = snapshot.snapshotItem(i).value; var query = { 'title': title, 'action': 'delete' }				var wikipedia_wiki = new Wikipedia.wiki( "Deleting " + title, query, twinklespeedy.callbacks.sysop.deleteRedirects ); wikipedia_wiki.params = params; wikipedia_wiki.onloading = onloading; wikipedia_wiki.onloaded = onloaded; wikipedia_wiki.onsuccess = onsuccess; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get; }		},		deleteRedirects: function( self ) { var form = this.responseXML.getElementById( 'deleteconfirm' ); if( ! form ) { // Hell, image deletion is b0rked :(				form = this.responseXML.getElementsByTagName( 'form' )[0];				var postData = {					'wpDeleteReasonList': 'other',					'wpReason': "Speedy deleted per (CSD R1), Redirect to deleted page \"" + wgPageName + "\"." + TwinkleConfig.deletionSummaryAd,					'wpEditToken': form.wpEditToken.value				}			} else {

var postData = { 'wpWatch': form.wpWatch.checked ? '' : undefined, 'wpDeleteReasonList': 'other', 'wpReason': "Speedy deleted per (CSD R1), Redirect to deleted page \"" + wgPageName + "\"." + TwinkleConfig.deletionSummaryAd, 'wpEditToken': form.wpEditToken.value }			}			self.post( postData ); },		unlinkImageInstancesMain: function( self ) { var xmlDoc = self.responseXML; var snapshot = xmlDoc.evaluate('//imageusage/iu/@title', xmlDoc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

if( snapshot.snapshotLength == 0 ) { return; }

var statusIndicator = new Status('Unlinking instances image', '0%');

var total = snapshot.snapshotLength * 2;

var onsuccess = function( self ) { var obj = self.params.obj; var total = self.params.total; var now = parseInt( 100 * ++(self.params.current)/total ) + '%'; obj.update( now ); self.statelem.unlink; if( self.params.current >= total ) { obj.info( now + ' (completed)' ); Wikipedia.removeCheckpoint; }			}			var onloaded = onsuccess;

var onloading = function( self ) {}

Wikipedia.addCheckpoint; if( snapshot.snapshotLength == 0 ) { statusIndicator.info( '100% (completed)' ); Wikipedia.removeCheckpoint; return; }

var params = clone( self.params ); params.current = 0; params.total = total; params.obj = statusIndicator; params.image = wgTitle;

for ( var i = 0; i < snapshot.snapshotLength; ++i ) { var title = snapshot.snapshotItem(i).value; var query = { 'title': title, 'action': 'submit' }				var wikipedia_wiki = new Wikipedia.wiki( "Unlinking on " + title, query, twinklespeedy.callbacks.sysop.unlinkImageInstances ); wikipedia_wiki.params = params; wikipedia_wiki.onloading = onloading; wikipedia_wiki.onloaded = onloaded; wikipedia_wiki.onsuccess = onsuccess; wikipedia_wiki.get; }		},		unlinkImageInstances: function( self ) { var form = self.responseXML.getElementById('editform'); var text = form.wpTextbox1.value; var old_text = text; var wikiPage = new Mediawiki.Page( text ); wikiPage.commentOutImage( self.params.image, 'Commented out because image was deleted' );

text = wikiPage.getText; if( text == old_text ) { // Nothing to do, return self.onsuccess( self ); Wikipedia.actionCompleted( self ); return; }			var postData = { 'wpMinoredit': form.wpMinoredit.checked ? '' : undefined, 'wpWatchthis': undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': 'Removing instance of image ' + self.params.image + " that has been speedily deleted per (CSD " + self.params.normalized.toUpperCase + ")" + "; " + TwinkleConfig.deletionSummaryAd, 'wpTextbox1': text };			self.post( postData ); },		deletePage: function( self ) { var form = this.responseXML.getElementById( 'deleteconfirm' ); if( ! form ) { // Hell, image deletion is b0rked :(				form = this.responseXML.getElementsByTagName( 'form' )[0];				var postData = {					'wpDeleteReasonList': 'other',					'wpReason': "Speedy deleted per (CSD " + self.params.normalized.toUpperCase + "), " + self.params.reason + "." + TwinkleConfig.deletionSummaryAd,					'wpEditToken': form.wpEditToken.value				}				self.post( postData );			} else {

var postData = { 'wpWatch': self.params.watch || form.wpWatch.checked ? '' : undefined, 'wpDeleteReasonList': 'other', 'wpReason': "Speedy deleted per (CSD " + self.params.normalized.toUpperCase + "), " + self.params.reason + "." + TwinkleConfig.deletionSummaryAd, 'wpEditToken': form.wpEditToken.value }				self.post( postData ); }		},		deleteTalkPage: function( self ) { form = this.responseXML.getElementById( 'deleteconfirm' );

var postData = { 'wpWatch': self.params.watch || form.wpWatch.checked ? '' : undefined, 'wpDeleteReasonList': 'other', 'wpReason': "Speedy deleted per (CSD g8), was a talk page of deleted page." + TwinkleConfig.deletionSummaryAd, 'wpEditToken': form.wpEditToken.value }			self.post( postData ); }	},	user: { main: function( self ) { var xmlDoc = self.responseXML;

var exists = xmlDoc.evaluate( 'boolean(//pages/page[not(@missing)])', xmlDoc, null, XPathResult.BOOLEAN_TYPE, null ).booleanValue;

if( ! exists ) { self.statelem.error( "It seems that the page doesn't exists, perhaps it has already been deleted" ); return; }			var query = { 'title': wgPageName, 'action': 'submit' };

var wikipedia_wiki = new Wikipedia.wiki( 'Tagging page', query, twinklespeedy.callbacks.user.tagPage ); wikipedia_wiki.params = self.params; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get; },		tagPage: function( self ) { form = this.responseXML.getElementById( 'editform' );

var text = form.wpTextbox1.value;

self.statelem.status( 'Checking for tags on the page...' );

var tag = /(\{\{(?:db-?|delete)\|?.*?\}\})/.exec( text );

if( tag ) { self.statelem.error( [ htmlNode( 'strong', tag[0] ), " is already placed on the page." ] ) return; }

var xfd = /(\{\{(?:[rsaitcm]fd|md1)[^{}]*?\}\})/i.exec( text );

if( xfd && !confirm( "The deletion related template " + xfd[0] + " is already present on the page, do you still want to apply CSD template?" ) ) {				return; }			var code; switch( self.params.normalized ) { case 'i8': var date = new Date; var code = "\{\{NowCommons|month=" + date.getUTCMonthName + "|day=" + date.getUTCDate + "|year=" + date.getUTCFullYear + "|1=" + wgPageName.replace( '_', ' ' ) + "\}\}"; break; case 'g6': switch( self.params.value ) { case 'histmerge': var title = prompt( 'please enter the title to merge into here' ); if( title == null ) { return; }					code = "\{\{db-" + self.params.value + "|1=" + title + "\}\}"; break; default: code = "\{\{db-" + self.params.value + "\}\}"; break;

}				break; case 'g12': var url = prompt( 'please enter url if available, including the http://' ); if( url == null ) { return; }				code = "\{\{db-" + self.params.value + "|url=" + url + "\}\}"; break; case 'i1': var img = prompt( 'enter the image this is redundant to, excluding the Image: prefix' ); if( img == null ) { return; }				code = "\{\{db-" + self.params.value + "|1=" + img + "\}\}"; break; case 't3': var template = prompt( 'enter the template this is redundant to, excluding the Template: prefix' ); if( template == null ) { return; }				code = "\{\{db-" + self.params.value + "|1=\~\~\~\~\~|2=" + template + "\}\}"; break; default: code = "\{\{db-" + self.params.value + "\}\}"; break; }

// Notification to first contributor var query = { 'action': 'query', 'prop': 'revisions', 'titles': wgPageName, 'rvlimit': 1, 'rvprop': 'user', 'rvdir': 'newer' }			var callback = function( self ) { var xmlDoc = self.responseXML; var user = xmlDoc.evaluate( '//rev/@user', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue; var query = { 'title': 'User talk:' + user, 'action': 'submit' };				var wikipedia_wiki = new Wikipedia.wiki( 'Notifying of initial contributor (' + user + ')', query, twinklespeedy.callbacks.user.userNotification ); wikipedia_wiki.params = self.params; wikipedia_wiki.get; }

if( self.params.usertalk ) { var wikipedia_api = new Wikipedia.api( 'Grabbing data of initial contributor', query, callback ); wikipedia_api.params = self.params; wikipedia_api.post; }

var postData = { 'wpMinoredit': TwinkleConfig.markSpeedyPagesAsMinor ? '' : undefined, 'wpWatchthis': self.params.watch ? '' : undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': "Requesting speedy deletion (CSD " + self.params.normalized.toUpperCase + ")." + TwinkleConfig.summaryAd, 'wpTextbox1': code + "\n" + text };			self.post( postData ); },		userNotification: function( self ) { var form = self.responseXML.getElementById( 'editform' ); var text = form.wpTextbox1.value; text += "\n\{\{subst:db-csd-notice-custom|1=" + wgPageName + "|2=" + self.params.value + "\}\} \~\~\~\~"; var postData = { 'wpMinoredit': form.wpMinoredit.checked ? '' : undefined, 'wpWatchthis': form.wpWatchthis.checked ? '' : undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': 'Notification: Speedy deletion nomination of \[\[' + wgPageName + '\]\].' + TwinkleConfig.summaryAd, 'wpTextbox1': text };			self.post( postData ); }	} }

twinklespeedy.callback.evaluateSysop = function twinklespeedyCallbackEvaluateSysop(e) {

wgPageName = wgPageName.replace( /_/g, ' ' ); // for queen/king/whatever and country!

var tag_only = e.target.form.tag_only; if( tag_only && tag_only.checked ) { return twinklespeedy.callback.evaluateUser(e); }

var value = e.target.value; var normalized = twinklespeedy.normalizeHash[ value ];

var params = { value: value, normalized: normalized, watch: TwinkleConfig.watchSpeedyPages.indexOf( normalized ) != -1, reason: twinklespeedy.reasonHash[ value ] };	Status.init( e.target.form );

var query = { 'action': 'query', 'titles': wgPageName }	var wikipedia_api = new Wikipedia.api( 'Checking if page exists', query, twinklespeedy.callbacks.sysop.main ); wikipedia_api.params = params; wikipedia_api.post; }

twinklespeedy.callback.evaluateUser = function twinklespeedyCallbackEvaluateUser(e) { wgPageName = wgPageName.replace( /_/g, ' ' ); // for queen/king/whatever and country! var value = e.target.value; var normalized = twinklespeedy.normalizeHash[ value ];

var params = { value: value, normalized: normalized, watch: TwinkleConfig.watchSpeedyPages.indexOf( normalized ) != -1, usertalk: TwinkleConfig.notifyUserOnSpeedyDeletionNomination.indexOf( normalized ) != -1 && e.target.form.notify.checked };

Status.init( e.target.form );

Wikipedia.actionCompleted.redirect = wgPageName; Wikipedia.actionCompleted.notice = "Tagging complete";

var query = { 'action': 'query', 'titles': wgPageName }

var wikipedia_api = new Wikipedia.api( 'Checking if page exists', query, twinklespeedy.callbacks.user.main ); wikipedia_api.params = params; wikipedia_api.post;

}

title: User:Flewis/twinklespeedy.js


text:
User:Flewis/twinklediff.js

function twinklediff { if( wgNamespaceNumber < 0 ) { return; }

var query = { 'title': wgPageName, 'diff': 'cur', 'oldid': 'prev' };

mw.util.addPortletLink( 'p-cactions', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ), 'last', 'tw-lastdiff', 'Show most recent diff' );

if( !QueryString.exists( 'diff' ) ) { // Not diff page return; }

var l = mw.util.addPortletLink( 'p-cactions', "javascript:twinklediff.evaluate(false);", 'since', 'tw-since', 'Show difference between last diff and the revision made by previous user' );

var l = mw.util.addPortletLink( 'p-cactions', "javascript:twinklediff.evaluate(true);", 'since mine', 'tw-sincemine', 'Show difference between last diff and my last revision' ); } $( twinklediff );

twinklediff.evaluate = function twinklediffEvaluate(me) { var ntitle = getElementsByClassName( document.getElementById('bodyContent'), 'td', 'diff-ntitle' )[0];

var user; if( me ) { user = wgUserName; } else { var node = document.getElementById( 'mw-diff-ntitle2' ); if( ! node ) { // nothing to do? return; }		user = document.evaluate( 'a[1]', node, null, XPathResult.STRING_TYPE, null ).stringValue; }	var query = { 'prop': 'revisions', 'action': 'query', 'titles': wgPageName, 'rvlimit': 1, 'rvprop': [ 'ids', 'user' ], 'rvstartid': wgCurRevisionId - 1, // i.e. not the current one 'rvuser': user };	Status.init( document.getElementById('bodyContent') ); var wikipedia_api = new Wikipedia.api( 'Grabbing data of initial contributor', query, twinklediff.callbacks.main ); wikipedia_api.params = { user: user }; wikipedia_api.post; }

twinklediff.callbacks = { main: function( self ) { var xmlDoc = self.responseXML; var revid = xmlDoc.evaluate( '//rev/@revid', xmlDoc, null, XPathResult.NUMBER_TYPE, null ).numberValue;

if( ! revid ) { self.statelem.error( 'no suitable earlier revision found, or ' + self.params.user + ' is the only contributor. Aborting.' ); return; }		var query = { 'title': wgPageName, 'oldid': revid, 'diff': wgCurRevisionId };		window.location = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ); } }

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: User:Flewis/twinklediff.js


text:
User:Flewis/twinkleprotect.js

// If TwinkleConfig aint exist. if( typeof( TwinkleConfig ) == 'undefined' ) { TwinkleConfig = function {}; }

/** TwinkleConfig.summaryAd (string) If ad should be added or not to summary, default TWINKLE */ if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) { TwinkleConfig.summaryAd = " using TW"; }

/** TwinkleConfig.protectionSummaryAd (string) If ad should be added or not to protection summary, default TWINKLE */ if( typeof( TwinkleConfig.protectionSummaryAd ) == 'undefined' ) { TwinkleConfig.protectionSummaryAd = " using TW"; }

function twinkleprotect { if( wgNamespaceNumber < 0 ) { return; }

if( userIsInGroup( 'sysop' ) ) { mw.util.addPortletLink( 'p-cactions', "javascript:twinkleprotect.callback", "pp", "tw-rpp", "Protect page", ""); } else if (twinkleConfigExists) { mw.util.addPortletLink( 'p-cactions', "javascript:twinkleprotect.callback", "rpp", "tw-rpp", "Request page protection", ""); }	else {		mw.util.addPortletLink('p-cactions', 'javascript:alert("Your account is too new to use Twinkle.");', 'rpp', 'tw-rpp', 'Request page protection', ''); } } $(twinkleprotect);

twinkleprotect.callback = function twinkleprotectCallback { var Window = new SimpleWindow( 600, 400 ); Window.setTitle( "Protection of pages" ); var form = new QuickForm( twinkleprotect.callback.evaluate ); if( userIsInGroup( 'sysop' ) ) { form.append( {				type: 'checkbox',				name: 'request_only',				event: twinkleprotect.callback.disabledefaults,				list: [					{						label: 'Request protection',						value: 'request_only',						tooltip: 'If you want to request protection via WP:RPP instead of doing the protection by your self.'					}				]			} ); }	form.append( {			type: 'select',			name: 'category',			label: 'Type of protection: ',			event: twinkleprotect.callback.disabledefaults,			list: [				{					label: 'Full protection',					list: [						{ label: 'Generic', value: 'pp-protected' },						{ label: 'Dispute', selected: wgCurRevisionId != false, value: 'pp-dispute' },						{ label: 'Vandalism', value: 'pp-vandalism' },						{ label: 'High visible template', value: 'pp-template' },						{ label: 'User talk of blocked user', value: 'pp-usertalk' }					]				},				{					label: 'Semi-protection',					list: [						{ label: 'Generic', value: 'pp-semi-protected' },						{ label: 'Vandalism', value: 'pp-semi-vandalism' },						{ label: 'High-visibility template', value: 'pp-semi-template' },						{ label: 'User talk of blocked user', value: 'pp-semi-usertalk' },						{ label: 'Spambot target', value: 'pp-semi-spambot' }					]				},				{ label: 'Other', list: [ { label: 'Move-protection', value: 'pp-move' }, { label: 'Create-protection', selected: wgCurRevisionId == false, value: 'pp-create' }, { label: 'Unprotection', value: 'unprotect' } ]				}			]		} );	var flags = form.append( { type: 'field', label: 'Options' } );

flags.append( {			type: 'checkbox',			list: [				{					name: 'noinclude',					label: 'Wrap ',					tooltip: 'Will wrap the template in tags, so that it won\'t transclude',					checked:(wgNamespaceNumber==10),					adminonly: true				},				{ 					name: 'small',					label: 'Iconify',					tooltip: 'Will use the |small=yes feature of the template, and only render it as a keylock',					adminonly: true				},				{					name: 'cascade',					label: 'Cascade protection',					tooltip: 'Cascade protection will protect all pages that is transcluded into said page'				}			]		} );

if( userIsInGroup( 'sysop' ) ) { form.append( {				type: 'select',				name: 'expiry',				label: 'Expiration: ',				event: function(event) {					var value = event.target.value;					event.target.form.small.disabled = value != 'indefinite';				},				list: [					{ label: '1 hour', value: '1 hour' },					{ label: '2 hours', value: '2 hours' },					{ label: '3 hours', value: '3 hours' },					{ label: '6 hours', value: '6 hours' },					{ label: '12 hours', value: '12 hours' },					{ label: '1 day', value: '1 day' },					{ label: '2 days', value: '2 days' },					{ label: '3 days', value: '3 days' },					{ label: '4 days', value: '4 days' },					{ label: '5 days', value: '5 days' },					{ label: '6 days', value: '6 days' },					{ label: '1 week', value: '1 week' },					{ label: '2 weeks', value: '2 weeks' },					{ label: '1 month', value: '1 month' },					{ label: '2 months', value: '2 months' },					{ label: '3 months', value: '3 months' }, { label: '6 months', value: '6 months' }, { label: '1 year', value: '1 year' }, { label: 'indefinite', selected: true, value:'indefinite' } ]			} );	} else {		form.append( { type: 'select', name: 'expiry', label: 'Expiration: ', event: function(event) { var value = event.target.value; event.target.form.small.disabled = value != 'indefinite'; },				list: [ { label: 'temporary', value: 'temporary' }, { label: 'indefinite', value: 'indefinite' }, { label: , selected: true, value: } ]			} );	}	form.append( { type: 'textarea', name: 'reason', label: 'Reason: ' } );	form.append( { type:'submit' } );	var result = form.render;	Window.setContent( result );	Window.display; }

twinkleprotect.callback.disabledefaults = function twinkleprotectCallbackDisableDefaults(e) { var root = e.target.form; if( e.target.value == 'unprotect' ) { root.noinclude.disabled = true; root.cascade.disabled = true; root.expiry.disabled = true; root.small.disabled = true; } else { root.noinclude.disabled = false; root.cascade.disabled = false; root.expiry.disabled = false; root.small.disabled = false; if( userIsInGroup( 'sysop' ) && root.request_only.checked ){ root.small.disabled = true; root.noinclude.disabled = true; }	}

if( /template/.test( e.target.value ) ) { root.noinclude.checked = true; root.expiry.disabled = true; } else { root.noinclude.checked = false; }

}

twinkleprotect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) { var form = e.target;

var params = { noinclude: form.noinclude.checked, cascade: form.cascade.checked, small: form.small.checked, reason: form.reason.value, expiry: form.expiry.value, type: form.category.value }

if( userIsInGroup( 'sysop') ) { var request_only = form.request_only.checked; if( request_only && params.expiry != 'indefinite' ) { params.expiry = 'temporary'; }	}

Status.init( form );

if( userIsInGroup( 'sysop' ) && ! request_only ) {

var edit, move, tag = params.type, reason, create = ''; switch( tag ) { case 'pp-dispute': edit = 'sysop'; move = 'sysop'; reason = 'Full protection: Dispute'; break; case 'pp-vandalism': edit = 'sysop'; move = 'sysop'; reason = 'Full protection: Vandalism'; break; case 'pp-template': edit = 'sysop'; move = 'sysop'; reason = 'Full protection: High-visible template'; break; case 'pp-usertalk': edit = 'sysop'; move = 'sysop'; reason = 'Full protection: User talk of blocked user'; break; case 'pp-protected': edit = 'sysop'; move = 'sysop'; if( params.reason ) { tag += '|reason=' + params.reason; params.reason = undefined; }			reason = 'Full protection'; break; case 'pp-semi-vandalism': edit = 'autoconfirmed'; move = 'autoconfirmed'; reason = 'Semi-protection: Vandalism'; break; case 'pp-semi-usertalk': edit = 'autoconfirmed'; move = 'autoconfirmed'; reason = 'Semi-protection: User talk of blocked user'; break; case 'pp-semi-template': edit = 'autoconfirmed'; move = 'autoconfirmed'; reason = 'Semi-protection: High-visible template'; break; case 'pp-semi-spambot': edit = 'autoconfirmed'; move = 'autoconfirmed'; reason = 'Semi-protection: Spambot target'; break; case 'pp-semi-protected': edit = 'autoconfirmed'; move = 'autoconfirmed'; if( params.reason ) { tag += '|reason=' + params.reason; params.reason = undefined; }			reason = 'Semi-protection'; break; case 'pp-move': edit = ''; move = 'sysop'; reason = 'Move-protection'; break; case 'pp-create': edit = ''; move = ''; create = 'sysop'; reason = 'Create-protection: \{\{pp-create\}\}'; break;

case 'unprotect': default: edit = ''; move = ''; reason = 'Unprotection'; break; }		if( params.reason ) { reason += ', ' + params.reason; }		reason += '.';

params.reason = reason; params.tag = tag; params.edit = edit; params.move = move; params.create = create;

var query = { 'title': wgPageName, 'action': 'submit' };

// Updating data for the action completed event Wikipedia.actionCompleted.redirect = query['title']; Wikipedia.actionCompleted.notice = "Done...";

if( create == '' ) { var wikipedia_wiki = new Wikipedia.wiki( 'Tagging page', query, twinkleprotect.callbacks.sysop.taggingPage ); wikipedia_wiki.params = params; wikipedia_wiki.get; }		var query = { 'title': wgPageName, 'action': 'protect' };

var wikipedia_wiki = new Wikipedia.wiki( 'Protecting page', query, twinkleprotect.callbacks.sysop.protectingPage ); wikipedia_wiki.params = params; wikipedia_wiki.get; } else { var typename, reason; switch( params.type ) { case 'pp-dispute': case 'pp-vandalism': case 'pp-template': case 'pp-usertalk': case 'pp-protected': typename = 'full protection'; break; case 'pp-semi-vandalism': case 'pp-semi-usertalk': case 'pp-semi-template': case 'pp-semi-spambot': case 'pp-semi-protected': typename = 'semi-protection'; break; case 'pp-move': typename = 'move-protection'; break; case 'pp-create': typename = 'create-protection'; break; case 'unprotect': default: typename = 'unprotection'; break; }		switch( params.type ) { case 'pp-dispute': reason = 'Dispute'; break; case 'pp-vandalism': reason = 'Vandalism'; break; case 'pp-template': reason = 'High-visible template'; break; case 'pp-usertalk': reason = 'User talk of blocked user'; break; case 'pp-protected': reason = ''; break; case 'pp-semi-vandalism': reason = 'Vandalism'; break; case 'pp-semi-usertalk': reason = 'User talk of blocked user'; break; case 'pp-semi-template': reason = 'High-visible template'; break; case 'pp-semi-spambot': reason = 'Spambot target'; break; case 'pp-semi-protected': reason = ''; break; case 'pp-move': reason = ''; break; case 'pp-create': reason = ''; break; case 'unprotect': default: reason = ''; break; }		if( reason != '' ) { reason = "" + reason + ""; }		if( params.reason ) { reason += ', ' + params.reason; }		if( reason != '' ) { reason += '.'; }

params.reason = reason; params.typename = typename;

var query = { 'title': 'Wikipedia:Requests for page protection', 'action': 'submit' };		// Updating data for the action completed event Wikipedia.actionCompleted.redirect = query['title']; Wikipedia.actionCompleted.notice = "Nomination completed, redirecting now to the discussion page";

var wikipedia_wiki = new Wikipedia.wiki( 'Requesting protection of page', query, twinkleprotect.callbacks.user ); wikipedia_wiki.params = params; wikipedia_wiki.get; } }

twinkleprotect.callbacks = { sysop: { taggingPage: function( self ) { var form = self.responseXML.getElementById( 'editform' ); var oldtag_re = /\s*(?: )?\s*\{\{\s*(pp-[^{}]*?|protected|(?:t|v|s|p-|usertalk-v|usertalk-s|sb|move)protected(?:2)?|protected template|privacy protection)\s*?\}\}\s*(?:<\/noinclude>)?\s*/gi;

var text = form.wpTextbox1.value;

text = text.replace( oldtag_re, '' );

if( self.params.type != 'unprotect' && self.params.expiry != 'indefinite' ) { self.params.tag += '|expiry='; if( this.params.small ) { self.params.tag += '|small=yes'; }			}

var summary; if( self.params.type == 'unprotect' ) { summary = 'removing protection template' + TwinkleConfig.summaryAd; } else { if( self.params.noinclude ) { text = " \{\{" + self.params.tag + "\}\} " + text; } else { text = "\{\{" + self.params.tag + "\}\}\n" + text; }				summary = "adding \{\{" + self.params.tag + "\}\}" + TwinkleConfig.summaryAd;

}			var postData = { 'wpMinoredit': form.wpMinoredit.checked ? '' : undefined, 'wpWatchthis': form.wpWatchthis.checked ? '' : undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': summary, 'wpTextbox1': text };

self.post( postData ); },		protectingPage: function( self ){ var form = self.responseXML.getElementById( 'mw-Protect-Form' ); var postData = { 'wpEditToken': form.wpEditToken.value, 'mwProtectWatch': form.mwProtectWatch.checked ? '' : undefined, 'mwProtectCascade': self.params.cascade ? '' : undefined, 'mwProtect-expiry': self.params.expiry != 'indefinite' ? self.params.expiry : undefined, 'mwProtect-level-edit': self.params.edit, 'mwProtect-level-move': self.params.move, 'mwProtect-level-create': self.params.create, 'mwProtect-reason': self.params.reason + TwinkleConfig.protectionSummaryAd };

self.post( postData ); }	},	user: function( self ) { var form = self.responseXML.getElementById( 'editform' );

var text = form.wpTextbox1.value;

var rppRe = new RegExp( '====.*?' + RegExp.escape( wgPageName, true ) + '.*?====', 'm' ); var tag = rppRe.exec( text );

if( tag ) { self.statelem.warn( [ htmlNode( 'strong', tag[0] ), " is alread placed on the page." ] ) return false; }

var ns2tag	=	{ '0'	:	'la', '1'	:	'lat', '2'	:	'lu', '3'	:	'lut', '4'	:	'lw', '5'	:	'lwt', '6'	:	'li', '7'	:	'lit', '8'	:	'lm', '9'	:	'lmt', '10':	'lt', '11':	'ltt', '12':	'lh', '13':	'lht', '14':	'lc', '15':	'lct', '100':	'lp', '101':	'lpt' };

var newtag = '==== \{\{' + ns2tag[ wgNamespaceNumber ] + '|' + wgTitle + '\}\} ====' + "\n"; if( ( new RegExp( '^' + RegExp.escape( newtag ).replace( /\s+/g, '\\s*' ), 'm' ) ).test( text ) ) { self.statelem.error( 'There are already a request available for this page, aborting.' ); return; }		var words = []; switch( self.params.expiry ) { case 'temporary': words.push( "temporary" ); break; case 'indefinite': words.push( "indefinite" ); break; }		if( self.params.cascade ) { words.push( "cascading" ); }

words.push( self.params.typename );

newtag += "" + words.join( ' ' ) + "" + ( self.params.reason !=  ? ' ' + self.params.reason :  ) + "\~\~\~\~";

if( self.params.type == 'unprotect' ) { var str = "==Current requests for unprotection==\n"; } else { var str = "==Current requests for protection==\n"; }		text = text.replace( str, str + "\n" + newtag + "\n" ); var postData = { 'wpMinoredit': undefined, 'wpWatchthis': form.wpWatchthis.checked ? '' : undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': "Requesting " + self.params.typename + ' of ' + wgPageName.replace('_', ' ') + '.' + TwinkleConfig.summaryAd, 'wpTextbox1': text };

self.post( postData ); } }

title: User:Flewis/twinkleprotect.js


text:
User:Flewis/twinkleprod.js

// If TwinkleConfig aint exist. if( typeof( TwinkleConfig ) == 'undefined' ) { TwinkleConfig = {}; }

/** TwinkleConfig.summaryAd (string) If ad should be added or not to summary, default TWINKLE */ if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) { TwinkleConfig.summaryAd = " using TW"; }

/** TwinkleConfig.watchProdPages (boolean) If, when applying prod template to page, watch it, default true */ if( typeof( TwinkleConfig.watchProdPages ) == 'undefined' ) { TwinkleConfig.watchProdPages = true; }

function twinkleprod { if( wgNamespaceNumber != 0 || wgCurRevisionId == false ) { return; }	if (twinkleConfigExists) {		mw.util.addPortletLink( 'p-cactions', "javascript:twinkleprod.callback", "prod", "tw-prod", "Propose deletion via WP:PROD", ""); }	else {		mw.util.addPortletLink('p-cactions', 'javascript:alert("Your account is too new to use Twinkle.");', 'prod', 'tw-prod', 'Propose deletion via WP:PROD', ''); } } $(twinkleprod);

twinkleprod.callback = function twinkleprodCallback { var Window = new SimpleWindow( 800, 400 ); Window.setTitle( "WP:PROD" ); var form = new QuickForm( twinkleprod.callback.evaluate ); var field = form.append( {			type: 'field',			label: 'Reason for proposed deletion'		} ); field.append( {			type: 'textarea',			name: 'reason',			label: 'Reason:'		} ); field.append( { type:'submit' } );

var result = form.render; Window.setContent( result ); Window.display; }

twinkleprod.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 callback = function( self ) { var xmlDoc = self.responseXML; var user = xmlDoc.evaluate( '//rev/@user', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue; var query = { 'title': 'User talk:' + user, 'action': 'submit' };			var wikipedia_wiki = new Wikipedia.wiki( 'Notifying of initial contributor (' + user + ')', query, twinkleprod.callbacks.userNotification ); wikipedia_wiki.params = self.params; wikipedia_wiki.get; }

var wikipedia_api = new Wikipedia.api( 'Grabbing data of initial contributor', query, callback ); wikipedia_api.params = self.params; wikipedia_api.post;

var postData = { 'wpMinoredit': undefined, // Per memo 'wpWatchthis': TwinkleConfig.watchProdPages ? '' : 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 ); },	userNotification: function( self ) { var form = this.responseXML.getElementById( 'editform' ); var text = form.wpTextbox1.value; text += "\n\{\{subst:PRODWarning|1=" + wgPageName + "\}\} \~\~\~\~"; var postData = { 'wpMinoredit': form.wpMinoredit.checked ? '' : undefined, 'wpWatchthis': form.wpWatchthis.checked ? '' : undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': 'PROD nomination of \[\[' + wgPageName + '\]\].' + TwinkleConfig.summaryAd, 'wpTextbox1': text };

self.post ( postData ); } }

twinkleprod.callback.evaluate = function twinkleprodCallbackEvaluate(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, twinkleprod.callbacks.main ); wikipedia_wiki.params = { reason: reason }; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get; }

title: User:Flewis/twinkleprod.js