Wikipédia:Scripts/Twinkle/salt.js
Aspeto
< Wikipédia:Scripts | Twinkle
//
$(saltPageTab); var saltTarget = "UWikipedia:Software/Scripts/Twinkle/Salt"; function saltPageTab() { if( wgCurRevisionId != false || wgNamespaceNumber < 0 || ! userIsInGroup( 'sysop' ) ) { return; } mw.util.addPortletLink('p-cactions', "javascript:saltPage()", "salt", "ca-salt", "Salt this page using cascading protection", ""); } function saltPage() { Status.init( document.getElementById('bodyContent') ); editXML = sajax_init_object(); editXML.overrideMimeType('text/xml'); var query = { 'title': saltTarget, 'action': 'submit' } Status.status( 'Finding page...' ); editXML.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ) , false); editXML.send( null ); var doc = editXML.responseXML; var form = doc.getElementById( 'editform' ); var title = wgPageName.replace( /_/g, ' ' ); var text = form.wpTextbox1.value; if( text.match( new RegExp( RegExp.escape(title) ) ) ) { Status.info( 'Already salted.' ); return; } text += '*{{:' + title + '}} <small>(Added by [[User:' + wgUserName + '|' + wgUserName + ']] on ~~~~~)</small>'; var postData = { 'wpSummary': 'Adding [[' + title + ']]', 'wpWatchthis': form.wpWatchthis.checked, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpEditToken': form.wpEditToken.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpTextbox1': text } Status.status( 'Adding ' + title + '...' ); editXML = sajax_init_object(); editXML.overrideMimeType('text/xml'); editXML.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ) , false); editXML.setRequestHeader('Content-type','application/x-www-form-urlencoded'); editXML.send( QueryString.create( postData ) ); Status.info( 'Salted.' ); } //