User:Steel359/salt.js

// Script written by User:AzaToth, taken from User:AzaToth/salt.js.

//

addOnloadHook(saltPageTab);

var saltTarget = "User:Steel359/Salt";

function saltPageTab { if( wgCurRevisionId != false || wgNamespaceNumber < 0 ) { 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 += '* ';

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.' );

}

//