User:Technical 13/sandbox.js

/* SpamUNblocker */ /* Notepad Icons of interest:
 * [[File:Crystal Clear app Login Manager.svg]] as a user info icon - //upload.wikimedia.org/wikipedia/commons/6/67/Crystal_Clear_app_Login_Manager.svg
 * [[File:Crystal Clear action info.svg]] as a "more" icon to activate a moreInfoPanel throwout - //upload.wikimedia.org/wikipedia/commons/e/ee/Crystal_Clear_action_info.svg
 * [[File:Crystal Clear action run.svg]] as an "options" icon to activate the optionsPanel throwout - //upload.wikimedia.org/wikipedia/commons/3/35/Crystal_Clear_action_run.svg
 * [[File:Crystal Clear action exit.svg]] as the close button - //upload.wikimedia.org/wikipedia/commons/4/4a/Crystal_Clear_action_exit.svg
 * [[File:Crystal Clear action button cancel.svg]] as the close button for failed - //upload.wikimedia.org/wikipedia/commons/7/7d/Crystal_Clear_action_button_cancel.svg
 * [[File:Crystal Clear app clean.svg]] as the close button for successfully completed - //upload.wikimedia.org/wikipedia/commons/6/61/Crystal_Clear_app_clean.svg



var sunbVersion = '0.1'; if ( window.screen.availWidth ) { var screenWidth = window.screen.availWidth; } else { var screenWidth = window.screen.width; } var uiCenter = ( ( screenWidth - 800 ) / 2 );

/* User prefs */// Create function to get script data here var userPrefs = {}; new mw.Api.get( {	// list of known block templates to subst: } ).done( function( templateList ) {	// Create an ajax enabled input type="text" based on retrieved data } );

var spunSiteInfo = [ ]; var spunUserInfo = { groups: [ ], blocked: { isBlocked: false } }; var spunContribInfo = { editCount: 0, edits: [ ] }; var spunPageInfo = { contributors: 0, contribs: [ ] }; /* Create the interface here */ var sunpMainPanel = ' Spam UserName Blocker ' + sunbVersion + '      Blocking Console:   <option value="infinite" selected="selected">indefinite  10 years  5 years  1 year <option value="other" onClick="otherDuration;">Other time:  Content section   '; function otherDuration { $( '#mw-input-wpExpiry' ).replaceWith( '<input id="mw-input-wpExpiry-other" style="width: 40%;" name="wpExpiry-other" class="mw-ui-input" value="indefinite" /><input id="listDuration-button" type="button" onClick="listDuration" value="▼" />' ); } function listDuration { $( '#listDuration-button' ).remove; $( '#mw-input-wpExpiry-other' ).replaceWith( '<select name="wpExpiry" id="mw-input-wpExpiry" style="width: 40%;" class="mw-htmlform-select-or-other"><option value="infinite" selected="selected">indefinite 10 years  5 years  1 year <option value="other" onClick="otherDuration;">Other time:  ' ); } function userPane { var sunpUserInfoPanel = '<div id="sunb-user-ui" class="sunb-ui" style="z-index: 1000; background-color: ' + ( ( spunUserInfo.gender === 'male' ) ? '#EEEEFF' : ( spunUserInfo.gender === 'female' ) ? '#FFEEEE' : '#FFFFEE' ) + '; padding: 4px; border: 1px solid #AAAAAA; border-radius: 6px; text-align: left; font-size: 11px; color: #000000; display: block; position: absolute; top: 100px; left: ' + ( uiCenter + 640 ) + 'px; width: 152px; height: 472px;"> User: <img src="//upload.wikimedia.org/wikipedia/commons/4/4a/Crystal_Clear_action_exit.svg" style="width: 16px; height: 16px;" /></a>  '; if ( spunUserInfo.blocked.isBlocked ) { var blockedAt = new Date( spunUserInfo.blocked.isBlockedTimestamp ); sunpUserInfoPanel += '<div id="sunb-user-blocked-box" style="background-color: #FFEEEE; border: 1px solid #FF3333; border-radius: 6px; padding: 2px;">'; sunpUserInfoPanel += 'Blocked by: ' + spunUserInfo.blocked.isBlockedBy + '</a> '; sunpUserInfoPanel += 'Blocked on: ' + blockedAt.toLocaleString + ' '; sunpUserInfoPanel += 'Block expires: ' + spunUserInfo.blocked.isBlockedExpiry + ' '; sunpUserInfoPanel += 'Block reason: ' + spunUserInfo.blocked.isBlockedReason + '</a> '; sunpUserInfoPanel += ' '; }	sunpUserInfoPanel += '  '; if ( $( '#sunb-page-ui' ).html !== undefined ) { $( '#sunb-page-ui' ).css( 'z-index', 999 ); }	if ( $( '#sunb-opt-ui' ).html !== undefined ) { $( '#sunb-opt-ui' ).css( 'z-index', 999 ); }	if ( $( '#sunb-user-ui' ).html !== undefined ) { $( '#sunb-user-ui' ).css( 'z-index', 1000 ).focus; } else { $( 'body' ).append( sunpUserInfoPanel ); } } function pagePane { var sunpPageInfoPanel = '<div id="sunb-page-ui" class="sunb-ui" style="z-index: 1000; background-color: #F0F0F0; padding: 4px; border: 1px solid #AAAAAA; border-radius: 6px; text-align: left; font-size: 11px; color: #000000; display: block; position: absolute; top: 100px; left: ' + ( uiCenter + 640 ) + 'px; width: 152px; height: 472px;"> Page: <img src="//upload.wikimedia.org/wikipedia/commons/4/4a/Crystal_Clear_action_exit.svg" style="width: 16px; height: 16px;" /></a>     '; if ( $( '#sunb-user-ui' ).html !== undefined ) { $( '#sunb-user-ui' ).css( 'z-index', 999 ); }	if ( $( '#sunb-opt-ui' ).html !== undefined ) { $( '#sunb-opt-ui' ).css( 'z-index', 999 ); }	if ( $( '#sunb-page-ui' ).html !== undefined ) { $( '#sunb-page-ui' ).css( 'z-index', 1000 ).focus; } else { $( 'body' ).append( sunpPageInfoPanel ); } } function optionsPane { var sunpOptionsPanel = '<div id="sunb-opt-ui" class="sunb-ui" style="z-index: 1000; background-color: #F0F0F0; padding: 4px; border: 1px solid #AAAAAA; border-radius: 6px; text-align: left; font-size: 11px; color: #000000; display: block; position: absolute; top: 100px; left: ' + ( uiCenter + 640 ) + 'px; width: 152px; height: 472px;"> Options: <img src="//upload.wikimedia.org/wikipedia/commons/4/4a/Crystal_Clear_action_exit.svg" style="width: 16px; height: 16px;" /></a>     '; if ( $( '#sunb-user-ui' ).html !== undefined ) { $( '#sunb-user-ui' ).css( 'z-index', 999 ); }	if ( $( '#sunb-page-ui' ).html !== undefined ) { $( '#sunb-page-ui' ).css( 'z-index', 999 ); }	if ( $( '#sunb-opt-ui' ).html !== undefined ) { $( '#sunb-opt-ui' ).css( 'z-index', 1000 ).focus; } else { $( 'body' ).append( sunpOptionsPanel ); } }

$.when(	new mw.Api.get( { action: 'query', meta: 'siteinfo', siprop: 'usergroups', continue: '' } ).done( function( siteInfo ) { for ( var s in siteInfo.query.usergroups ) { spunSiteInfo[ s ] = siteInfo.query.usergroups[ s ].name; }	} ), /* spammerInfo */// Create function to get some information on the spammer here	new mw.Api.get( { action: 'query', list: 'users', usprop: [ 'blockinfo', 'groups', 'implicitgroups', 'rights', 'editcount', 'registration', 'emailable', 'gender' ], ususers: mw.config.get( 'wgRelevantUserName' ), continue: '' } ).done( function( spammerInfo ) { spunUserInfo.userid = spammerInfo.query.users[ 0 ].userid; spunUserInfo.editCount = spammerInfo.query.users[ 0 ].editcount; spunUserInfo.registration = spammerInfo.query.users[ 0 ].registration; spunUserInfo.groups = spammerInfo.query.users[ 0 ].groups; if ( spammerInfo.query.users[ 0 ].blockid ) { spunUserInfo.blocked.isBlocked = true; spunUserInfo.blocked.isBlockId = spammerInfo.query.users[ 0 ].blockid; spunUserInfo.blocked.isBlockedBy = spammerInfo.query.users[ 0 ].blockedby; spunUserInfo.blocked.isBlockedById = spammerInfo.query.users[ 0 ].blockedbyid; spunUserInfo.blocked.isBlockedTimestamp = spammerInfo.query.users[ 0 ].blockedtimestamp; spunUserInfo.blocked.isBlockedReason = spammerInfo.query.users[ 0 ].blockreason; spunUserInfo.blocked.isBlockedExpiry = spammerInfo.query.users[ 0 ].blockexpiry; }		spunUserInfo.gender = spammerInfo.query.users[ 0 ].gender; spunUserInfo.emailable = ( spammerInfo.query.users[ 0 ].emailable === undefined ) ? false : true; } ),

/* spamContribInfo */// Create function to get some information on the spammer's contributions here new mw.Api.get( {		action: 'query',		list: 'usercontribs',		ucuser: mw.config.get( 'wgRelevantUserName' ),		ucprop: [ 'title', 'timestamp', 'parsedcomment', 'patrolled', 'flags' ],		uclimit: 'max',		continue: ''	} ).done( function( spamContribInfo ) {		for ( var i in spamContribInfo.query.usercontribs ) {			spunContribInfo.edits[ spunContribInfo.editCount ] = {				user: spamContribInfo.query.usercontribs[ i ].user,				title: spamContribInfo.query.usercontribs[ i ].title,				timestamp: spamContribInfo.query.usercontribs[ i ].timestamp,				flags: { },				parsedcomment: spamContribInfo.query.usercontribs[ i ].parsedcomment			};			spunContribInfo.edits[ spunContribInfo.editCount ].flags.isNew = ( spamContribInfo.query.usercontribs[ i ].new === undefined ) ? false : true;			spunContribInfo.edits[ spunContribInfo.editCount ].flags.isTop = ( spamContribInfo.query.usercontribs[ i ].top === undefined ) ? false : true; spunContribInfo.edits[ spunContribInfo.editCount ].flags.isMinor = ( spamContribInfo.query.usercontribs[ i ].minor === undefined ) ? false : true; spunContribInfo.edits[ spunContribInfo.editCount ].flags.isBot = ( spamContribInfo.query.usercontribs[ i ].bot === undefined ) ? false : true; spunContribInfo.edits[ spunContribInfo.editCount ].flags.isPatrolled = ( spamContribInfo.query.usercontribs[ i ].patrolled === undefined ) ? false : true; spunContribInfo.editCount++; }		if ( spunContribInfo.editCount === 1 && spunContribInfo.edits.length === 0 ) { spunContribInfo.contributors--; }	} ),

/* spamPageInfo */// Create function to get some information on the spammer's user page here new mw.Api.get( {		action: 'query',		prop: 'revisions',		titles: mw.config.get( 'wgPageName' ),		rvprop: [ 'ids', 'timestamp', 'parsedcomment', 'user', 'flags', 'tags' ],		rvlimit: 'max',		continue: ''	} ).done( function( spamPageInfo ) {		/* Not sure how I want to populate the object for this just yet */		for ( var h in spamPageInfo.query.pages ) {			for ( var i in spamPageInfo.query.pages[ h ].revisions ) {					spunPageInfo.contribs[ spunPageInfo.contributors ] = {					revId: spamPageInfo.query.pages[ h ].revisions[ i ].revid,					timestamp: spamPageInfo.query.pages[ h ].revisions[ i ].timestamp,					parsedcomment: spamPageInfo.query.pages[ h ].revisions[ i ].parsedcomment,					user: spamPageInfo.query.pages[ h ].revisions[ i ].user					/* flags and tags -  not sure how I want them yet */				};			}			spunPageInfo.contributors++;		}		if ( spunPageInfo.contributors === 1 && spunPageInfo.contribs.length === 0 ) { spunPageInfo.contributors--; }	} ) ).done( function {	/* define a couple little things once all data is gathered */	spunContribInfo.deletedEditCount = ( spunUserInfo.editCount - spunContribInfo.editCount );	/* Add link to run script */	var SPAMblocker = mw.util.addPortletLink( 'p-cactions', '#',		'SPAMblock', 'pt-spamblock', 'Delete page as spam, block account, notify editor on talk page.', null, null );	$( SPAMblocker ).click( function ( e ) { e.preventDefault; /* Call the interface here */ $( 'body' ).append( sunpMainPanel ); console.info(spunUserInfo); console.info(spunContribInfo); console.info(spunPageInfo); } ); } );

function blockSpamer { /* Create the blocking function here */ // }

function notifySpamer { /* Create the notificaiton function here */ // }

function deleteSpam { /* Create the function to delete spam pages here */ // }

/* End of script */