//<pre>
function addlink(url, name)
{
var na = document.createElement('a');
na.setAttribute('href', 'https://dictious.com/en/' + 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 pipe(td)
{
td.appendChild(document.createTextNode(' | '));
}
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 t(txt)
{
return '{{' + txt + '}}';
}
function sig()
{
return ' ~~' + '~~';
}
function template(tm)
{
document.editform.wpTextbox1.value = t(tm) + '\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = t(tm);
}
function user_talk_template(tm, sum)
{
if (document.editform.wpTextbox1.value.length > 0)
document.editform.wpTextbox1.value += '\n';
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + t(tm) + sig() + '\n';
document.editform.wpSummary.value = sum;
}
function transwiki_history()
{
var txt = document.editform.wpTextbox1;
// Account for my history-munging javascript at en.wikipedia
txt.value = txt.value.replace(/VndTstBlkMsc /g, "");
// Replace double braces, add a newline at end
txt.value = txt.value.replace(/{/g, "{") + "\n";
txt.value = txt.value.replace(/}/g, "}");
// Find minor edits, and make them regexp-friendly
txt.value = txt.value.replace(/ m \(/g, " (MINOR");
txt.value = txt.value.replace(/ m$/gm, " (MINOR)");
// Find edits without summaries, and make them regexp-friendly
txt.value = txt.value.replace(new RegExp("()\\r", "gm"), "$1 ()\r");
// Replace the "(cur) (last) " at the start of each line with "*" and link user names
txt.value = txt.value.replace(new RegExp("^\\(cur\\) \\(last\\) (:, ? * 200) (*) (\\(.*\\))$", "gm"), "*$1 ] $3");
// Fix minor edits
txt.value = txt.value.replace(/ \(MINOR/g, " '''m''' (");
// Fix edits without summaries
txt.value = txt.value.replace(/ \(\)$/gm, "");
txt.value = txt.value.replace(new RegExp("^(*) \\((.*)\\)$", "gm"), "$1 ''($2)''");
// Add header
var title;
if (!document.title.match(/Talk:Transwiki:(.*) - (Preview|Edit)/))
title = prompt("Couldn't find article name.");
else
title = RegExp.$1;
txt.value = "This article was ]ed from ]." + sig() + "\n\nThe history of the article there was:\n" + txt.value;
// And summary
document.editform.wpSummary.value = "]ed from ]";
}
function transwiki_summary()
{
var txt = document.editform.wpTextbox1;
var title;
if (!document.title.match(/Editing Transwiki:(.*) - (Preview|Edit)/))
title = prompt("Couldn't find article name.");
else
title = RegExp.$1;
document.editform.wpSummary.value = "]ed from ]";
}
function transwiki_log(title)
{
var txt = document.editform.wpTextbox1;
txt.value += "*] → ]" + sig();
document.editform.wpSummary.value = "] transwikied from ]";
}
function interwiki(lk, td, a, host, abbrev)
{
host = lk.replace(/source/, host);
td.insertBefore(addexplicitlink(host, abbrev), a);
if (abbrev == "D" || abbrev == "d")
{
td.insertBefore(document.createTextNode('/'), a);
td.insertBefore(addexplicitlink(host.toLowerCase(), "lc"), a);
}
td.insertBefore(document.createTextNode(' | '), a);
}
function morelinks()
{
var table = document.getElementById('topbar').getElementsByTagName('table');
var tds = table.getElementsByTagName('td');
var td = tds;
var lks = td.getElementsByTagName('a');
var a;
var txt;
var lk;
// Add comment link to top, and replace Main Page with Transwiki log
for (a = 0; a < lks.length; ++a)
{
txt = lks.childNodes.data;
if (txt == "Main Page")
{
lks.childNodes.data = "TrLog";
lks.setAttribute('href', "https://en.wiktionary.org/w/index.php?title=Wiktionary:Transwiki log/Articles moved to here/staging");
}
else if (txt == "Edit this page")
{
txt = lks.getAttribute('href');
a = lks;
td.insertBefore(addexplicitlink(txt + "§ion=new", "Comment"), a);
td.insertBefore(document.createTextNode(' | '), a);
td.insertBefore(addexplicitlink(txt + "§ion=0", "0"), a);
td.insertBefore(document.createTextNode(' | '), a);
break;
}
}
if (document.title.indexOf("User:Cryptic/standard") >= 0)
{
a = td.getElementsByTagName('p');
td.insertBefore(document.createTextNode(' | '), a);
td.insertBefore(addexplicitlink("https://en.wiktionary.org/w/index.php?title=User:Cryptic/standard.js&action=raw&ctype=text/javascript", "js"), a);
td.insertBefore(document.createTextNode(' | '), a);
td.insertBefore(addexplicitlink("https://en.wiktionary.org/w/index.php?title=User:Cryptic/standard.css&action=raw&ctype=text/css", "css"), a);
}
// 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');
while (td.hasChildNodes())
{
lk = td.firstChild;
if (lk.nodeName == 'A' && lk.firstChild.data == 'Current revision')
{
a = tds.getElementsByTagName('p');
tds.insertBefore(document.createTextNode(' | '), a);
tds.insertBefore(lk, a);
}
else if (lk.nodeName == 'STRONG' && lk.firstChild.data == 'You have ')
{
lks = tds.getElementsByTagName('a');
for (a = 0; a < lks.length; ++a)
if (lks.firstChild.data == 'Talk')
{
lks.firstChild.data = 'New Messages';
lks.setAttribute('style', 'font-style: italic;');
lks.setAttribute('href', 'https://en.wiktionary.org/w/index.php?title=User_talk:Cryptic&action=history');
}
}
td.removeChild(td.firstChild);
}
// Replace them
td.appendChild(addlink('Special:Watchlist', 'Watchlist'));
pipe(td);
td.appendChild(addlink('Special:Randompage', 'Random'));
pipe(td);
td.appendChild(addexplicitlink('https://en.wiktionary.org/w/index.php?title=Special:Contributions&hideminor=0&target=Cryptic&limit=500&offset=0', 'Contribs'));
pipe(td);
td.appendChild(addlink('Special:Specialpages', 'Special'));
pipe(td);
td.appendChild(addlink('Wiktionary Appendix:IPA Examples', 'IPA'));
if (document.title.indexOf("Editing ") == 0)
{
pipe(td);
td.appendChild(addexplicitlink('javascript:replace()', 'Replace'));
if (document.title.indexOf("Editing Talk:Transwiki:") == 0)
{
pipe(td);
td.appendChild(addexplicitlink('javascript:transwiki_history()', 'Fixup Transwiki history'));
}
else if (document.title.indexOf("Editing Transwiki:") == 0)
{
pipe(td);
td.appendChild(addexplicitlink('javascript:transwiki_summary()', 'Transwiki summary'));
}
else if (document.title.indexOf("Editing Wiktionary:Transwiki log") == 0)
{
pipe(td);
td.appendChild(addexplicitlink('javascript:transwiki_log(prompt("Title?"))', 'Log entry'));
}
}
// Interwiki links
td = tds;
a = td.firstChild;
lks = document.getElementsByTagName('a');
for (lk = lks.length - 1; lk >= 0 && lks.firstChild.data != 'What links here'; --lk);
if (lk >= 0)
{
lk = lks.getAttribute('href');
lk = lk.replace(/en.wiktionary/, "source");
lk = lk.replace(/Special:Whatlinkshere&target=/, "");
interwiki(lk, td, a, "en.wikipedia", "w");
interwiki(lk, td, a, "en.wiktionary", "D");
interwiki(lk, td, a, "en.wikinews", "n");
interwiki(lk, td, a, "en.wikibooks", "b");
interwiki(lk, td, a, "wikisource", "s");
interwiki(lk, td, a, "commons.wikimedia", "c");
interwiki(lk, td, a, "meta.wikimedia", "m");
interwiki(lk, td, a, "en.wikiquote", "q");
}
}
function do_onload()
{
morelinks();
}
if (window.addEventListener)
window.addEventListener("load", do_onload, false);
else if (window.attachEvent)
window.attachEvent("onload", do_onload);
//</pre>