User:Danny~enwikisource/monobook.js

// Last update: 18:53, 24 February 2006 (UTC) // // Automatic soft-redirect // Uses w:WP:JS addlilink

$(function {	if(document.forms.editform) {		var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];		addlilink(tabs, 'javascript:softRedirect;', 'Soft redirect', 'ca-redirect');		addlilink(tabs, 'javascript:addHeader;', 'Blank header', 'ca-header');	} });

function addHeader { var txt = document.getElementById('wpTextbox1'); txt.value = "\n"+txt.value; }

function softRedirect{ var txt = document.editform.wpTextbox1; var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?(\\[\\^\\*\\]\\])[\\S\\s]*|[\\s\\S]*", "g"), "$1"); if (r==""){ var r = ""+prompt('What page should the redirect point to?')+""; }	txt.value = ""+r+""; var summary = document.editform.wpSummary; summary.value = "Converted to soft redirect"; }

/*** Add generic tab ***/ function addlilink(tabs, url, name, id){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; }

//