User:Shirik/spm.js

// // Note: Requires WP:TW to work // Special thanks to the Twinkle project on which this project is based // This code is released under the GNU General Public License v2

importScript("User:Shirik/spm_whitelist.js");

// Load hook function spm {  if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {    mw.util.addPortletLink("p-cactions", "javascript:spm.ltaCallback", "LTA", "spm-lta", "Report user for long-term abuse", ""); } }

var spmWhitelistedUsers = ["Daedalus969", "Shirik", "Bsadowski1"];

// Callback from the WP API spm.callbacks = {  tagUser: function(self) {     // Tag as suspected sockpuppet form = this.responseXML.getElementById( 'editform' ); var text = ""; var postData = { 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSection': '', 'wpSummary': 'Tagging as a sockpuppet of ' + self.params.name + (self.params.link ==  ?  : ' per ' + self.params.link + '') + ' (SPM)', 'wpTextbox1' : text };       self.post(postData);

// Now report to AIV var query = { 'action': 'submit', 'title': 'Wikipedia:Administrator intervention against vandalism', 'section': 1 };     var wikipedia_wiki = new Wikipedia.wiki('Reporting to AIV', query, spm.callbacks.aiv); wikipedia_wiki.params = self.params; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get; },  aiv: function(self) {     var form = self.responseXML.getElementById('editform'); var text = form.wpTextbox1.value;

// check to ensure the user is not yet reported var re = new RegExp( "\\{\\{\\s*(?:(?:[Ii][Pp])?[Vv]andal|[Uu]serlinks)\\s*\\|\\s*(?:1=)?\\s*" + RegExp.escape( self.params.user, true ) + "\\s*\\}\\}" ); if (re.exec(text)) {        self.statelem.error("The user has already been reported to AIV; will not add another report"); }     else {        self.statelem.info("Adding new report..."); var postData = { 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSection': form.wpSection.value, 'wpSummary': "Reporting LTA sock " + (self.params.link ==  ? "" + self.params.user + " (SPM)",           'wpTextbox1': text + '*\{\{vandal|1=' + self.params.user + '\}\} - Long-term abuse sockpuppet of User:' + self.params.name + ' ' + (self.params.link ==  ?  : '(see ' + self.params.link + ') ') +  + ''         }           self.post(postData);      }   } }

if (spmWhitelistedUsers.indexOf(wgUserName) != -1) { addOnloadHook(spm); }

// Callback for the form spm.ltaExecute = function spmLtaExecute(e) {  var value = e.target.value; var split = value.split("|"); var name = split[0]; var link = (split.length == 1) ? '' : split[1]; var params = { 'name': name, 'link': link, 'user': wgPageName.substring(5) };

Status.init(e.target.form); Wikipedia.actionCompleted.redirect = "WP:AIV"; Wikipedia.actionCompleted.notice = "Report complete"; var query = { 'action': 'submit', 'title': wgPageName };

var wikipedia_wiki = new Wikipedia.wiki('Tagging user page', query, spm.callbacks.tagUser); wikipedia_wiki.params = params; wikipedia_wiki.followRedirect = false; wikipedia_wiki.get; }

// Callback for clicking the option spm.ltaCallback = function spmLtaCallback {  var Window = new SimpleWindow( TwinkleConfig.speedyWindowWidth, TwinkleConfig.speedyWindowHeight ); Window.setTitle("Choose sockpuppet information"); var form = new QuickForm(spm.ltaExecute, 'change'); form.append({type: 'header', label: 'Sockmaster'});

// Fill in the options form.append({    type: 'radio',     name: 'lta',     list: [         {            label: 'Wallflowers98',            value: 'Wallflowers98|WP:LTA/WF98',            tooltip: 'Prolific vandal engaging in repetitive bad faith copyright violations, primarily 4shared.com'         },         {            label: 'JI Hawkins',            value: 'JI Hawkins|WP:LTA#Sanders_conspiracy_vandal',            tooltip: 'Prolific sockmaster inserting content regarding government conspiracies into articles, especially regarding Adam Sandler, Colonel Sanders, and the Men in Black'         },         {            label: 'Andreisme',            value: 'Andreisme',            tooltip: 'Prolific sockmaster asking disruptive questions pertaining to Nikola Tesla and areas around Southern California'         }     ]   });

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