User:Korath/standard.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Korath/standard. This user script seems to have an accompanying .css page at User:Korath/standard.css. |
// <nowiki>
function addlink(url, name)
{
var na = document.createElement('a');
na.setAttribute('href', '/wiki/' + url);
var txt = document.createTextNode(name);
na.appendChild(txt);
return na;
}
function addexplicitlink(url, name)
{
var na = document.createElement('a');
na.setAttribute('href', url);
var txt = document.createTextNode(name);
na.appendChild(txt);
return na;
}
function closevfd(bold, notbold, discuss)
{
var txt = document.editform.wpTextbox1;
txt.value = "{{" + "subst:vt}} '''" + bold + "'''" + notbold + discuss + ". ~~" + "~~\n" + txt.value + "\n{{" + "subst:vb}}\n";
txt = document.editform.wpSummary;
txt.value = "close discussion: " + bold + notbold;
}
function replace()
{
var s = prompt("Search regexp?");
if (s)
{
var r = prompt("Replace regexp?");
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
}
function vfdresult()
{
var txt = document.editform.wpSummary;
txt.value = "Vfd result";
txt = document.editform.wpTextbox1;
if (txt.value.length > 0)
txt.value += '\n';
txt.value += "==Vfd==\nOn [[April ]], [[2005]], this article was nominated for deletion. The result was . See [[Wikipedia:Votes for deletion/{{" +
"subst:PAGENAME}}]] for a record of the discussion. ~~" + "~~";
txt.focus();
}
function header_vfd()
{
var start = document.title.indexOf('/'), end = document.title.indexOf(' - Edit this page - Wikipedia, the free encyclopedia');
document.editform.wpTextbox1.value = '===[[' + document.title.substring(start + 1, end) + ']]===\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'header';
}
function complete_vfd()
{
header_vfd();
document.editform.wpTextbox1.value += "[[User:|User:]] marked this vfd on , but never made a subpage or listed it on vfd. I'm just bringing it here for resolution; do not consider this a vote. ~~" + "~~";
document.editform.wpSummary.value = 'complete nom';
document.editform.wpTextbox1.focus();
}
function relist_vfd()
{
document.editform.wpTextbox1.value += "*'''Comment''': This was apparently either never listed on vfd or removed out of process, so I'm bringing it to today's page for resolution. ~~" + "~~";
document.editform.wpSummary.value = 'relist';
document.editform.wpTextbox1.focus();
}
function morelinks()
{
var table = document.getElementById('topbar').getElementsByTagName('table')[0];
var tds = table.getElementsByTagName('td');
var td = tds[1];
var lks = td.getElementsByTagName('a');
var a;
var txt;
var lk;
// Add comment link to top
for (a = 0; a < lks.length; ++a)
{
txt = lks[a].childNodes[0].data;
if (txt == "Edit this page")
{
txt = lks[a].getAttribute('href') + "§ion=new";
a = lks[a + 1];
td.insertBefore(addexplicitlink(txt, "Comment"), a);
td.insertBefore(document.createTextNode(' | '), a);
break;
}
}
// Remove second line, preserving "Current revision" (on the first line) and
// "You have new messages" (replacing (Talk) in upper right) if present
td = td.getElementsByTagName('p')[0];
while (td && td.hasChildNodes())
{
lk = td.firstChild;
if (lk.nodeName == 'A' && lk.firstChild.data == 'Current revision')
{
a = tds[1].getElementsByTagName('p')[0];
tds[1].insertBefore(document.createTextNode(' | '), a);
tds[1].insertBefore(lk, a);
}
else if (lk.nodeName == 'STRONG' && lk.firstChild.data == 'You have ')
{
lks = tds[2].getElementsByTagName('a');
for (a = 0; a < lks.length; ++a)
if (lks[a].firstChild.data == 'Talk')
{
lks[a].firstChild.data = 'New Messages';
lks[a].setAttribute('style', 'font-style: italic;');
lks[a].setAttribute('href', '/w/index.php?title=User_talk:Korath&action=history');
}
}
td.removeChild(td.firstChild);
}
// Replace them
if (document.title.indexOf("Editing Wikipedia:Votes for deletion") != -1)
{
td.appendChild(addexplicitlink('javascript:closevfd("keep", "", "")', 'KEEP'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:closevfd("merge and redirect", " to [[" + prompt("Merge and redirect to?") + "]]", "")', 'MERGE'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:closevfd("redirect", " to [[" + prompt("Redirect to?") + "]]", "")', 'REDIR'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:closevfd("transwiki", " to " + prompt("Transwiki to?"), "")', 'TRANS'));
td.appendChild(document.createTextNode('/'));
td.appendChild(addexplicitlink('javascript:closevfd("transwiki", " to Wiktionary", "")', 'WIKI'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:closevfd("speedy delete", "", "")', 'SPEEDY'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:closevfd("no consensus", "", "; thus, the article is kept")', 'NO/C'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:closevfd(prompt("Result?"), "", "")', 'MISC'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:header_vfd()', 'Header'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:complete_vfd()', 'Complete'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:relist_vfd()', 'Relist'));
}
else if (document.title.indexOf("Editing ") != -1)
{
td.appendChild(addexplicitlink('javascript:replace()', 'Replace'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('javascript:vfdresult()', 'VfDRslt'));
}
else
{
td.appendChild(addlink('Special:Watchlist', 'Watchlist'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addlink('Special:Randompage', 'Random'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addexplicitlink('/w/index.php?title=Special:Contributions&target=Korath&limit=500', 'Contribs'));
td.appendChild(document.createTextNode(' | '));
td.appendChild(addlink('Special:Specialpages', 'Special'));
}
}
// Change section links in vfd log pages to edit the entire subpage, instead of its section
function vfdsectionlinks()
{
var divs = document.getElementsByTagName("div");
var a;
var url;
var pos;
for (var x = 0; x < divs.length; ++x)
if (divs[x].className == "editsection")
{
a = divs[x].getElementsByTagName('a')[0];
url = a.getAttribute('href');
pos = url.indexOf("action=edit§ion=");
if (pos != -1)
{
url = url.substring(0, pos + 11);
a.setAttribute('href', url);
}
}
}
function do_onload()
{
morelinks();
if (document.title.indexOf("My watchlist") != -1)
{
var lks = document.getElementsByTagName('a');
for (var n = 0; n < lks.length; ++n)
if (lks[n].innerHTML == 'diff')
lks[n].href = lks[n].href.replace(/&curid=[0-9]+/, '');
}
}
if (window.addEventListener)
window.addEventListener("load", do_onload, false);
else if (window.attachEvent)
window.attachEvent("onload", do_onload);
// </nowiki>