User:Jafeluv/blockToolbox.js

// // Automatize block notifications for the most common block reasons.

var pageTitle = document.getElementById('firstHeading').getElementsByTagName('span')[0].innerHTML;

function userWarning(template, summary) { var form = document.editform; var textBox = form.wpTextbox1; if(textBox.value == '') { textBox.value = ''; } else { textBox.value += ''; } form.wpSummary.value = summary; form.wpWatchthis.checked = false; if(form.wpMinoredit) {   form.wpMinoredit.checked = false; } }

function userpageTag(template, summary, cursor) { var form = document.editform; var textBox = form.wpTextbox1; textBox.value = ''; if(cursor) {   textBox.focus; textBox.setSelectionRange(cursor, cursor); } form.wpSummary.value = summary; form.wpWatchthis.checked = false; if(form.wpMinoredit) {   form.wpMinoredit.checked = false; } }

// Add toolbox function addBlockToolbox(title) { var toolboxElement = document.getElementById("p-tb"); var patrollingElement= toolboxElement.cloneNode(true); patrollingElement.id="p-block"; patrollingElement.innerHTML = " " + title + "  "; toolboxElement.parentNode.insertBefore(patrollingElement, toolboxElement.nextSibling); } jQuery( document ).ready( function( $ ) { // Toolbox menu for user notification.  if (pageTitle.match(/(Editing|Creating) User talk:/)) {    addBlockToolbox("Block notice");    mw.util.addPortletLink("p-block", "javascript:userWarning('uw-spamublock|sig=yes', 'block notice');", "Spam block");    mw.util.addPortletLink("p-block", "javascript:userWarning('uw-ublock|sig=yes', 'block notice');", "Username block");    mw.util.addPortletLink("p-block", "javascript:userWarning('uw-softerblock|sig=yes', 'block notice');", "Softer block");    mw.util.addPortletLink("p-block", "javascript:userWarning('uw-uhblock|sig=yes', 'block notice');", "Hard block");    mw.util.addPortletLink("p-block", "javascript:userWarning('uw-soablock|sig=yes', 'block notice');", "Spam-only block");    mw.util.addPortletLink("p-block", "javascript:userWarning('uw-vaublock|sig=yes', 'block notice');", "Vandal-only username block"); mw.util.addPortletLink("p-block", "javascript:userWarning('uw-ipevadeblock|sig=yes', 'block notice');", "IP evade block"); document.getElementById('p-block').getElementsByTagName('div')[0].style.display = 'block'; } // Sockpuppet tagging. else if (pageTitle.match(/(Editing|Creating) User:/)) { addBlockToolbox("Sock tag"); mw.util.addPortletLink("p-block", "javascript:userpageTag('sockpuppeteer|blocked', 'sockpuppeteer tag', null);", "Master"); mw.util.addPortletLink("p-block", "javascript:userpageTag('sockpuppeteer|blocked|checked=yes', 'sockpuppeteer tag', null);", "Master (confirmed)"); mw.util.addPortletLink("p-block", "javascript:userpageTag('sockpuppet||blocked', 'sock tag', 13);", "Sock"); mw.util.addPortletLink("p-block", "javascript:userpageTag('sockpuppet||confirmed', 'confirmed sock', 13);", "Sock (confirmed)"); document.getElementById('p-block').getElementsByTagName('div')[0].style.display = 'block'; }

// Automatic sock category creation. var pattern = /Creating Category:(Suspected )?Wikipedia sockpuppets of (.*)/ var match = pageTitle.match(pattern); if(match) {   var form = document.editform; var textBox = form.wpTextbox1; textBox.value = ''; form.wpSummary.value = 'create sock category'; form.wpWatchthis.checked = false; } }); //