//<nowiki>
function add_global_style(css)
{
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head)
return;
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
function add_link_general(url, action, name, id, node, prev)
{
var na = document.createElement('a');
na.setAttribute('href', url);
var txt = document.createTextNode(name);
na.appendChild(txt);
if (id)
na.id = id;
if (action)
{
if (typeof action == "string")
na.setAttribute("onClick", action);
else if (typeof action == "function")
na.onclick = action;
}
if (node)
if (prev)
node.insertBefore(na, prev);
else
node.appendChild(na);
else
return na;
}
function addexplicitlink(url, name, node, prev)
{
return add_link_general(url, null, name, null, node, prev);
}
function addlink_onclick(action, name, node, prev)
{
return add_link_general('#', action, name, null, node, prev);
}
function pipe(node, txt, prev)
{
if (node)
if (prev)
node.insertBefore(document.createTextNode(txt ? txt : ' | '), prev);
else
node.appendChild(document.createTextNode(txt ? txt : ' | '));
else
return document.createTextNode(' | ');
}
function makebutton(lbl, action)
{
var button = document.createElement('input');
button.type = 'button';
button.value = lbl;
button.setAttribute('onClick', action);
return button;
}
// Add links for Logs, Current version, Enable rollback.
// Restore Talk: and non-Talk: links to the footer for pages not in namespaces besides Article: and Talk:.
// Fix the non-Talk: link in namespace Talk:, which normally goes to itself (!)
// Copy the more-informative label for Undelete on the (hidden) left navbar to the Undelete link on the bottom.
// If there's a template providing a default delete reason, display that in a delete link at the bottom, retaining the no-reason delete link.
// If it's a redirect-to-existent-page reason, provide the name of the target page.
// If this page is a redirect to a non-existent page, do the same.
function morelinks()
{
// Talk/non-Talk links. I don't want to speculate on the moon logic that removed them from every namespace *except* 0 and 1.
// Since they're still present for namespaces 0 and 1, be sure to put them in the same place those appear (after "Watch"), instead of before Protect like I'll do for the others.
var watch = document.getElementById("ca-cb-watch") || document.getElementById("ca-cb-unwatch");
if (watch)
{
var ns = mw.config.get('wgNamespaceNumber');
var title = mw.config.get('wgTitle');
// not negative namespaces (Special: and Media:), and don't duplicate in namespaces 0 and 1
if (ns > 1)
{
// I'd use mw.config.get('wgFormattedNamespaces'), except it's not always there in time. At least not in greasemonkey, where I'm prototyping this so folks can only point and laugh at a *working* illiterate version of it instead of broken ones.
var ns_title = mw.config.get('wgCanonicalNamespace');
ns_title = ns_title.replace(/^Project/, 'Wikipedia'); // 4/5, the only ones we localize
var parent = watch.parentNode;
// Contributions and Block links
if (ns == 2 || ns == 3)
{
var basetitle = title.replace(/\/.*/, '');
addexplicitlink("/w/index.php?title=" + encodeURIComponent('Special:Contributions/' + basetitle),
'Contribs', parent, watch.nextSibling);
pipe(parent, null, watch.nextSibling);
addexplicitlink("/w/index.php?title=" + encodeURIComponent('Special:Block/' + basetitle),
'Block', parent, watch.nextSibling);
pipe(parent, null, watch.nextSibling);
}
var linkname;
if (ns % 2)
{
ns -= 1;
ns_title = ns_title.replace(/_talk$/, '');
linkname = ns_title;
}
else
{
ns += 1;
ns_title += '_talk';
linkname = "Talk";
}
addexplicitlink("/w/index.php?title=" + encodeURIComponent(ns_title + ':' + title),
linkname, parent, watch.nextSibling);
pipe(parent, null, watch.nextSibling);
}
else if (ns == 1) // there's still a link in the Talk: namespace... but it's to the *same page*, and titled Talk. Doesn't anyone ever look at this stuff before deploying it?
{
var lk = document.getElementById('ca-cb-talk').firstChild;
if (lk.nodeName == 'A')
{
lk.href = "/w/index.php?title=" + encodeURIComponent(title);
var txt = lk.firstChild;
if (txt.nodeName == '#text')
txt.nodeValue = 'Article';
}
}
}
var enable_rollback_txt = "var head=document.getElementsByTagName('head')[0];"
+ "var style=document.createElement('style');"
+ "style.type='text/css';"
+ "style.innerHTML='.mw-rollback-link { display:inline !important; }';"
+ "head.appendChild(style);";
// If there's a protect link, add link for Logs and Current version.
// Always add a link for Enable rollback.
var protect = document.getElementById("ca-cb-unprotect");
if (!protect)
protect = document.getElementById("ca-cb-protect");
if (protect)
{
var parent = protect.parentNode;
pipe(parent, null, protect);
addexplicitlink("/w/index.php?title=Special:Log&page=" + encodeURIComponent(mw.config.get('wgPageName')),
'Logs', parent, protect);
pipe(parent, null, protect);
addexplicitlink("/w/index.php?title=" + encodeURIComponent(mw.config.get('wgPageName')),
'Curr', parent, protect);
pipe(parent, null, protect);
addlink_onclick(enable_rollback_txt, 'Enable rollback', parent, protect);
}
else
{
var parent = document.getElementById("searchform-footer").parentNode;
addlink_onclick(enable_rollback_txt, 'Enable rollback', parent);
}
var del = document.getElementById("ca-cb-undelete");
if (!del)
{
del = document.getElementById("ca-cb-delete");
if (del)
{
var delete_reason = document.getElementById("delete-reason");
if (delete_reason)
{
delete_reason = delete_reason.firstChild.nodeValue;
if (delete_reason)
{
if (delete_reason.match(/Redirect.*to\+a\+deleted\+or\+non-existent\+page/))
{
delete_reason = encodeURIComponent("[[WP:CSD#G8|G8]]: Redirect to a deleted or nonexistent page");
for (var node = document.getElementById('mw-content-text').firstChild.firstChild; node; node = node.nextSibling)
if (node.tagName == 'OL' && node.firstChild)
{
var n = node.firstChild;
if (n.tagName != 'LI' && n.nextSibling)
n = n.nextSibling;
if (n.tagName == 'LI')
{
delete_reason += ": [[" + n.firstChild.nextSibling.firstChild.nodeValue + "]]";
break;
}
}
}
else if (delete_reason.match(/Cross.*namespace.+redirect.+from.+mainspace/))
{
delete_reason = encodeURIComponent("[[WP:CSD#R2|R2]]: [[WP:XNR|Cross-namespace redirect]] from mainspace");
for (var node = document.getElementById('mw-content-text').firstChild.firstChild; node; node = node.nextSibling)
if (node.tagName == 'OL' && node.firstChild)
{
var n = node.firstChild;
if (n.tagName != 'LI' && n.nextSibling)
n = n.nextSibling;
if (n.tagName == 'LI')
{
delete_reason += " to [[" + n.firstChild.nextSibling.firstChild.nodeValue + "]]";
break;
}
}
}
else if (delete_reason.match(/^CSD.F5:/))
delete_reason = encodeURIComponent('[[WP:CSD#F5|F5]]: Unused non-free media file for more than 7 days');
else
delete_reason = delete_reason.replace("+", "%20", "g");
addexplicitlink(del.firstChild.href + "&wpReason=" + delete_reason,
decodeURIComponent(delete_reason),
del.parentNode, del.nextSibling);
pipe(del.parentNode, ': ', del.nextSibling);
}
}
else
{
for (var node = document.getElementById('mw-content-text').firstChild.firstChild; node; node = node.nextSibling)
{
if (node.tagName == 'OL'
&& node.firstChild
&& node.firstChild.nextSibling
&& node.firstChild.nextSibling.tagName == 'LI'
&& node.firstChild.nextSibling.firstChild
&& node.firstChild.nextSibling.firstChild.nodeName == '#text'
&& node.firstChild.nextSibling.firstChild.nodeValue.match(/^redirect *$/i)
&& node.firstChild.nextSibling.firstChild.nextSibling.tagName == 'A')
node = node.firstChild.nextSibling.firstChild.nextSibling;
else if (node.tagName == 'DIV'
&& node.className == 'redirectMsg'
&& node.firstElementChild
&& node.firstElementChild.nextElementSibling
&& node.firstElementChild.nextElementSibling.tagName == 'UL'
&& node.firstElementChild.nextElementSibling.firstChild
&& node.firstElementChild.nextElementSibling.firstChild.tagName == 'LI'
&& node.firstElementChild.nextElementSibling.firstChild.firstChild
&& node.firstElementChild.nextElementSibling.firstChild.firstChild.tagName == 'A')
node = node.firstElementChild.nextElementSibling.firstChild.firstChild;
else
continue;
if (node.className == 'new')
delete_reason = "[[WP:CSD#G8|G8]]: Redirect to a deleted or nonexistent page: [[" + node.firstChild.nodeValue + "]]";
else if (node.firstChild.nodeValue.match(/^(Talk|(Draft|User)([_ ]talk)?):/i))
delete_reason = "[[WP:CSD#R2|R2]]: [[WP:XNR|Cross-namespace redirect]] from mainspace to [[" + node.firstChild.nodeValue + "]]";
else
break;
addexplicitlink(del.firstChild.href + "&wpReason=" + encodeURIComponent(delete_reason),
delete_reason,
del.parentNode, del.nextSibling);
pipe(del.parentNode, ': ', del.nextSibling);
break;
}
}
}
}
else // Show number of deleted revisions in undelete link at bottom
{
var sidenode = document.getElementById("ca-undelete");
if (sidenode)
del.firstChild.firstChild.nodeValue = sidenode.firstChild.firstChild.nodeValue;
}
}
// If a template, wikilink, or external link appears in a diff, make it clickable
function link_links_dim_refs_in_diffs()
{
var tds = document.getElementsByTagName('td');
for (var i = 0; i < tds.length; ++i)
{
var classes = tds[i].className.split(' ');
for (var j = 0; j < classes.length; j++)
if (classes[j] == 'diff-context' || classes[j] == 'diff-addedline' || classes[j] == 'diff-deletedline')
{
var txt = tds[i].innerHTML;
if (txt.indexOf("&@<my") < 0)
{
txt = txt.replace(new RegExp('<(/?(del|ins)( class="[^""]*")?)>', 'g'), '&@<mybra;$1&@<myket;');
txt = txt.replace(new RegExp('(<ref[^<>]*?(/>|\\bref\\b( *>)?))', 'gi'), '<span style="opacity:0.25; font-size:x-small !important;">$1</span>');
txt = txt.replace(new RegExp('&@<mybra;', 'g'), '<');
txt = txt.replace(new RegExp('&@<myket;', 'g'), '>');
}
txt = txt.replace(new RegExp('(\\[ *)(https?:\\/\\/[^\\] <]+)([\\] ])', 'gi'), '$1<a href="$2">$2</a>$3');
txt = txt.replace(new RegExp('\\{\\{((?:talk|user|wikipedia|image|mediawiki|template|help|category|portal)(?:[ _]talk)?:[^\\}|<]+)([\\}|])', 'gi'), '{{<a href="https://en.wikipedia.org/wiki/$1">$1</a>$2');
txt = txt.replace(new RegExp('\\{\\{(\\s*(?:tlsp|lts|tl[xps]?)\\s*\\|\\s*|\\s*)([^\\}|<]+)([\\}|])', 'g'), '{{$1<a href="https://en.wikipedia.org/wiki/Template:$2">$2</a>$3');
function enwikilk(match, p1, p2, p3){ return p1 + '<a href="https://en.wikipedia.org/wiki/' + p2.replace(/ +/g, '_') + '">' + p2 + '</a>' + p3; };
txt = txt.replace(new RegExp('(\\[\\[:?)([^\\]|<]+)([\\]|])', 'g'), enwikilk);
txt = txt.replace(new RegExp('(\\[\\[[^\\]|]*<SPAN class="[^"]*">:?)([^\\]|<]+)(</SPAN>[\\]|])', 'gi'), enwikilk);
txt = txt.replace(new RegExp('\\b(url\\s*=\\s*)(https?://[^\\]|{} <>]+?)(\\s*(\\||\\}\\}))', 'gi'), '$1<a href="$2">$2</a>$3');
tds[i].innerHTML = txt;
break;
}
}
}
function cesarb_fixDiffOverflowTableCell(cell)
{
var div = document.createElement('div');
div.style.overflow = 'auto';
cell.insertBefore(div, cell.firstChild);
while (div.nextSibling)
div.appendChild(div.nextSibling);
}
function cesarb_fixDiffOverflowTable(table)
{
var cells = table.getElementsByTagName('td');
for (var i = 0; i < cells.length; i++)
{
var cell = cells[i];
var classes = cell.className.split(' ');
for (var j = 0; j < classes.length; j++)
if (classes[j] == 'diff-context' || classes[j] == 'diff-addedline' || classes[j] == 'diff-deletedline' || classes[j] == 'diff-otitle' || classes[j] == 'diff-ntitle')
{
cesarb_fixDiffOverflowTableCell(cell);
break;
}
}
}
function cesarb_fixDiffOverflowLoadListener(evt)
{
var tables = document.getElementsByTagName('table');
loop:
for (var i = 0; i < tables.length; i++)
{
var table = tables[i];
var classes = table.className.split(' ');
for (var j = 0; j < classes.length; j++)
if (classes[j] == 'diff')
{
cesarb_fixDiffOverflowTable(table);
link_links_dim_refs_in_diffs();
break loop;
}
}
}
function check_reason_length(node)
{
if (node.value.length > node.maxLength
&& (node.maxLength > 0 || node.value.length > 255))
node.style = "background-color:pink";
else
node.style = "background-color:white";
}
function should_watch(txt)
{
return (!txt.match(/^\[\[WP:CSD#(C1|G7|G8|G13|U1)\|/)
|| txt.match(/^\[\[WP:CSD#G8\|.*[rR]edirect to a/));
}
/* In no particular order:
* 1. Expands the delete dropdownlist to show all its contents instead of just
* the currently-selected line.
* 2. Move the "Additional reasons" input, the watchlist checkbox, and the
* delete button above the newly-expanded dropdownlist, so they're always in
* the same place.
* 3. Whenever an item is selected from the dropdownlist, immediately insert it
* into the "Additional reasons" input for further editing, then reselect the
* first option.
* 4. Add a button to clear the reason line.
* 5. If a preset deletion reason, or adding reasons from the dropdownlist,
* force the deletion reason above its maximum length, color the input pink
* so I know it'll be truncated. */
function expand_delete_dropdown_etc()
{
var reasons = document.getElementById('wpDeleteReasonList');
if (!reasons)
return;
/* Remove the warnings. Seeing them 50000 times was enough. The right way
* to do it is to put them in a named div, but some busybody is sure to raise
* a fuss if I edit [[MediaWiki::Confirmdeletetext]]. Life's too short. */
var delreason = document.getElementById('Deletereason');
if (delreason)
{
var p = delreason.parentNode; // "You are about to delete [[{{PAGENAME}}]] along with all of its history. Please:"
var ul = p.previousElementSibling; // "*Confirm...", "*Review...", "*Check...", "*Provide..."
if (ul.nodeName == 'UL')
{
p = ul.previousElementSibling;
var div = p.previousElementSibling; // "WARNING: Other pages link to..." Duh. *Always* present, because of the user pages that uselessly transclude [[CAT:CSD]].
if (p.nodeName == 'P')
{
p.parentNode.removeChild(p);
ul.parentNode.removeChild(ul);
}
if (div && div.nodeName == 'DIV')
div.parentNode.removeChild(div);
}
}
// OOjs considered harmful
//$(".oo-ui-dropdownInputWidget").removeClass("oo-ui-dropdownInputWidget");
//$(".oo-ui-dropdownInputWidget-php").removeClass("oo-ui-dropdownInputWidget-php");
/* Expand the whole list. We actually create a new one, copy the elements
* from the old one into there, and hide the old one, to minimize interference
* from hostile developers. */
var nsel = document.createElement('select');
var len = 0;
// Create an empty option to keep selected, since "Other reason" was removed
function add_option(grp, lbl)
{
var nop = document.createElement('option');
nop.value = lbl;
nop.appendChild(document.createTextNode(lbl));
grp.appendChild(nop);
return 1;
};
len += add_option(nsel, '');
var g1_seen = 0;
var optgroups = reasons.getElementsByTagName('optgroup');
for (var i = 0; i < optgroups.length; ++i)
{
var og = optgroups[i];
// Skip the talk section (we put it with the primary g8)
if (!og.label.match(/talk pages/i))
{
var nog = document.createElement('optgroup');
nog.label = og.label;
nsel.appendChild(nog);
++len;
var options = og.getElementsByTagName('option');
for (var j = 0; j < options.length; ++j)
{
var txt = options[j].value;
// enable G1 and G2 in all namespaces, to be used in extremis
if (txt.match(/^\[\[WP:CSD#G1\|G1\]\].+/))
g1_seen = 1;
else if (txt.match(/^\[\[WP:CSD#G3\|G3\]\].+/) && !g1_seen)
{
len += add_option(nog, "[[WP:CSD#G1|G1]]: [[WP:PN|Patent nonsense]], meaningless, or incomprehensible");
len += add_option(nog, "[[WP:CSD#G2|G2]]: Test page");
g1_seen = 1; // so it isn't added again on the next g3
}
// add G8 talk pages right before g10 (in particular, so it isn't removed for user talk subpages)
else if (txt.match(/^\[\[WP:CSD#G10\|G10\]\].+/))
len += add_option(nog, "[[WP:CSD#G8|G8]]: Talk page of a nonexistent or deleted page");
// essentially all G13s are drafts now, not afc-templated user subpages
else if (txt.match(/^\[\[WP:CSD#G13\|G13\]\].+/))
txt = txt.replace(/ or \[\[WP:AFC\|Articles for Creation\]\] submission/, '');
// Entirely the wrong place to try to teach admins which articles can be A7d
else if (txt.match(/^\[\[WP:CSD#A7\|A7\]\].+/))
txt = txt.replace(/ \(indiv.+/, '');
// the text for U5 is vague and antagonistic
else if (txt.match(/^\[\[WP:CSD#U5\|U5\]\].+/))
txt = txt.replace(/Misuse of Wikipedia as a web host/, "Writings unrelated to Wikimedia's goals, by a user with few or no edits outside of userspace");
// more specific link for R2
else if (txt.match(/^\[\[WP:CSD#R2\|R2\]\].+/))
txt = txt.replace(/Cross-\[\[WP:NS\|namespace\]\] \[\[WP:R\|redirect\]\]/, "[[WP:XNR|Cross-namespace redirect]]");
len += add_option(nog, txt);
}
}
}
nsel.id = 'nsel';
nsel.size = len;
var root = document.getElementById('mw-delete-table');
var div = document.createElement('div');
// Move the additional reason input, watch checkbox, and delete button above it, so they're always in the same place
var reason;
var deletebutton;
var imgtable = document.getElementById('mw-img-deleteconfirm-table');
if (imgtable)
{
reason = imgtable.getElementsByTagName('tr')[1]; // probably not, but I'll worry about it the next time I delete an image
reason.id = 'actual_reason';
deletebutton = imgtable.getElementsByTagName('tr')[3].getElementsByClassName('mw-submit')[0].firstElementChild;
}
else
{
reason = document.getElementById('wpReason').firstChild;
reason.id = 'actual_reason';
deletebutton = document.getElementById('wpConfirmB');
}
var spacer = document.createElement('span');
spacer.style = "margin-left:1em";
var watch = document.getElementById('wpWatch').parentNode;
var watchlabel = watch.nextElementSibling;
var clearbutton = makebutton('clear',
'var reason = document.getElementById("actual_reason");'
+ 'reason.value="";'
+ 'reason.style="background-color:white";'
+ 'reason.focus()');
clearbutton.style = "margin-left:1em";
div.appendChild(deletebutton);
div.appendChild(spacer);
div.appendChild(watch);
div.appendChild(watchlabel);
div.appendChild(clearbutton);
div.appendChild(reason);
div.appendChild(nsel);
for (var n = root.firstChild; n; n = n.nextSibling)
n.style.display='none';
root.appendChild(div);
/* Whenever clicking something in the reason dropdown, insert it into the
* additional-reasons input, reselect "other reason", and unflag watched for
* c1/g7/g8/g13/u1 */
nsel.onchange = function()
{
var reason = document.getElementById('actual_reason');
var sel = this.selectedIndex;
if (sel != 0) // 0 is "Other reason"
{
var txt = this[this.selectedIndex].firstChild.textContent;
if (reason.value.length > 0)
reason.value += '; ';
reason.value += txt;
check_reason_length(reason);
document.getElementById('wpWatch').checked = should_watch(this[this.selectedIndex].value);
this.selectedIndex = 0;
reason.focus();
}
};
/* And set initial value of wpWatch for c1/g7/g8/g13/u1. If initially g8, and
* deleting a talk page, then don't change watched status. */
var reasonv = document.getElementById('actual_reason').value;
if (reasonv.match(/^\[\[WP:CSD#G8\|.*[tT]alk page.*of a (deleted|non.?exist)/))
document.getElementById('wpWatch').firstChild.checked = !!document.getElementById("ca-cb-unwatch");
else
document.getElementById('wpWatch').firstChild.checked = should_watch(reasonv);
/* Whenever anything forces the length of the additional-reasons input above
* its max, change its background color */
reason.oninput = function(){ check_reason_length(this); };
// And initially, e.g. from presets
check_reason_length(reason);
reason.focus();
/* More oo-ui detritus - it keeps multiplying, and this one even unhides
* itself *AND* reinserts itself if removed!! Unbefuckinglievable. So hide
* it globally. */
add_global_style('.oo-ui-dropdownWidget { display:none !important; }');
}
// Open up to 20 history pages from watchlist, starting here and going up
function openahah(kk)
{
var as = document.getElementsByTagName('a');
var j = 0, k = 0;
++kk;
for (var n = 0; n < as.length; ++n)
if (as[n].innerHTML == 'hist' && kk - k++ <= 20)
{
if (k <= kk)
{
as[n].setAttribute('class', as[n].getAttribute('class') + ' modified');
window.open(as[n].href, '_blank');
}
else
break;
}
}
// Add "ahah" links to watchlist - "all histories above here".
// Also makes the "diff" links on watchlist match those on the history page, so marking the one visited changes the color of the other.
function addahah()
{
var as = document.getElementsByTagName('a');
var k = 0;
for (var n = 0; n < as.length; ++n)
{
if (as[n].innerHTML == 'diff')
as[n].href = as[n].href.replace(/&curid=[0-9]+&diff=([0-9]+)&oldid=[0-9]+/, '&diff=prev&oldid=$1');
else if (as[n].innerHTML == 'hist')
{
addexplicitlink('javascript:openahah(' + (k++) + ')', 'ahah', as[n].parentNode, as[n].nextSibling);
pipe(as[n].parentNode, ') (', as[n].nextSibling);
}
}
}
// Shows only the most recent change to each article listed in Special:RecentChangesLinked/articlename, like on Special:Watchlist, instead of all changes
function fix_relatedchanges()
{
var uls = document.getElementsByTagName('ul');
var entries = new Object;
for (var i = 0; i < uls.length; ++i)
if (uls[i].className && uls[i].className.indexOf('special') >= 0)
{
var ul = uls[i];
var li = ul.getElementsByTagName('li');
for (var j = 0; j < li.length; ++j)
{
var a = li[j].getElementsByTagName('a');
if (a[0].firstChild.data == 'diff')
if (entries[a[2].href] == 'y')
li[j].style.display = 'none';
else
{
a[0].href = a[0].href.replace(/&curid=[0-9]+/, '');
entries[a[2].href] = 'y';
}
}
}
}
// For each redirect link on Special:WhatLinksHere, add a "delete G8" link next to it to delete it with deletion summary prefilled
function add_g8redir_links()
{
var tgt = null;
var wlh = document.getElementById('mw-whatlinkshere-list');
if (wlh)
for (var li = wlh.firstChild; li; li = li.nextSibling)
if (li.firstChild
&& li.firstChild.firstChild
&& li.firstChild.firstChild.href
&& li.firstChild.firstChild.href.indexOf('&redirect=no') != -1
&& (li.firstChild.nextSibling.nodeValue.indexOf('(redirect page)') != -1
|| li.firstChild.nextSibling.nodeValue.indexOf('(redirect to section ') != -1))
{
if (!tgt)
tgt = "&action=delete&wpReason="
+ encodeURIComponent("[[WP:CSD#G8|G8]]: Redirect to a deleted or nonexistent page: [[" + mw.config.get('wgRelevantPageName') + "]]").replace('_', '+', 'g').replace('%20', '+', 'g')
+ "&action=delete";
var newnode = addexplicitlink(li.firstChild.href + tgt, 'delete G8');
// Place on the same line, whether there are incoming links to this redirect or not
var x;
for (x = li.firstElementChild; x; x = x.nextElementSibling)
if (x.tagName && x.tagName == 'UL')
{
li.insertBefore(newnode, x);
break;
}
if (!x)
li.appendChild(newnode);
}
}
// Move the notifications indicator from the sidebar (which I've hidden in css) to the bottom
function move_notif(notif)
{
var a = notif.firstChild;
notif = a.firstChild;
if (a.className.indexOf('mw-echo-notifications-badge-all-read') < 0 && a.className.indexOf('mw-echo-unseen-notifications') >= 0)
{
var search = document.getElementById("searchform-footer");
if (search)
{
var newnode = document.createElement("a");
newnode.setAttribute("class", "mw-echo-unread-notifications");
newnode.setAttribute("href", "/wiki/Special:Notifications");
newnode.appendChild(document.createTextNode("*"));
search.parentNode.insertBefore(newnode, search);
}
}
}
function move_notifications_to_bottom()
{
var notif1 = document.getElementById("pt-notifications-alert");
if (notif1)
move_notif(notif1);
var notif2 = document.getElementById("pt-notifications-notice");
if (notif2)
move_notif(notif2);
}
// Replace the useless link to [[Wikipedia:About]] in the footer with the current time in UTC. Click to update rather than automatic, since it's occasionally useful to know when I loaded the page.
function current_time_in_footer()
{
var footer = document.getElementById("footer-navigation");
if (footer)
for (var n = footer.firstChild; n; n = n.nextSibling)
{
if (n.tagName == 'BR')
n.style.display = 'none';
else if (n.tagName == 'UL')
for (var nn = n.firstChild; nn; nn = nn.nextSibling)
if (nn.firstChild && nn.firstChild.tagName == 'A' && nn.firstChild.href.indexOf('Wikipedia:About') > 0)
{
var span = document.createElement('span');
span.appendChild(document.createTextNode(new Date().toUTCString()));
span.setAttribute('onClick', 'this.firstChild.textContent = new Date().toUTCString();');
var olda = nn.firstChild;
nn.insertBefore(span, olda);
nn.removeChild(olda);
return;
}
}
}
document.my = new Object;
function modifyWatchlist(title, action)
{
if (title == null)
title = mw.config.get('wgPageName');
var reqData = {
'action': 'watch',
'format': 'json',
'title': title,
'token': mw.user.tokens.get('watchToken'),
'uselang': mw.config.get('wgUserLanguage')
};
if (action === 'unwatch')
reqData.unwatch = '';
jQuery.ajax(
{
url: mw.util.wikiScript('api'),
dataType: 'json',
type: 'POST',
data: reqData,
success: function(data, textStatus, xhr)
{
if (action == 'unwatch')
{
document.my.watchlk.style.display="inline";
document.my.unwatchlk.style.display="none";
}
else
{
document.my.watchlk.style.display="none";
document.my.unwatchlk.style.display="inline";
}
}
});
}
document.my.modifyWatchlist = modifyWatchlist;
function fix_watch_links()
{
try
{
var watched = false;
var bot = document.getElementById("ca-cb-watch");
if (!bot)
{
bot = document.getElementById("ca-cb-unwatch");
if (!bot)
return;
watched = true;
}
bot.firstChild.style.display = "none";
var a = document.createElement("a");
a.setAttribute("href", "javascript:document.my.modifyWatchlist(mw.util.getParamValue('title'), 'watch');");
a.appendChild(document.createTextNode('Watch'));
bot.appendChild(a);
document.my.watchlk = a;
if (watched)
a.style.display = "none";
a = document.createElement("a");
a.setAttribute("href", "javascript:document.my.modifyWatchlist(mw.util.getParamValue('title'), 'unwatch');");
a.appendChild(document.createTextNode('Unwatch'));
bot.appendChild(a);
document.my.unwatchlk = a;
if (!watched)
a.style.display = "none";
}
catch (e)
{
}
}
function add_open10()
{
// >> on image categories
if (mw.config.get('wgPageName').indexOf('Category:Orphaned_non-free_use_Wikipedia_files_as_of') == 0
|| mw.config.get('wgPageName').indexOf('Category:Wikipedia_files') == 0)
{
var div = document.getElementById('mw-category-media');
if (div)
for (var ul = div.firstChild; ul; ul = ul.nextSibling)
if (ul.tagName == 'UL' && ul.className.indexOf('mw-gallery-traditional') >= 0)
{
var count = 0;
var first = 0;
for (var node = ul.firstChild; ; node = node.nextSibling)
{
if (node && node.tagName == 'LI')
if (++count == 1)
first = node;
if (count == 11 || (!node && count != 0))
{
var newnode = document.createElement("br");
ul.insertBefore(newnode, first);
newnode = document.createElement("a");
newnode.setAttribute("onClick", "var i,n=this;for(i=0;i<"+count+";++i){n=n.nextSibling;if(!n)break;if(n.tagName!='LI'){n=n.nextSibling;if(!n)break;}window.open(n.firstChild.firstChild.nextSibling.firstChild.firstChild.href,'_blank');}");
newnode.setAttribute("href", "#");
newnode.appendChild(document.createTextNode('>>'));
ul.insertBefore(newnode, first);
count = 0;
first = 0;
}
if (!node)
break;
}
}
}
// open10 on non-image categories
if (mw.config.get('wgPageName') == 'Category:Non-free_files_with_orphaned_versions_more_than_7_days_old'
|| mw.config.get('wgPageName').indexOf('Category:Candidates_for_speedy_deletion') == 0
|| mw.config.get('wgPageName').indexOf('Category:Candidates_for_uncontroversial_speedy_deletion') == 0
|| mw.config.get('wgPageName').indexOf('Category:Wikipedia_files') == 0)
{
var start = 1;
var div = document.getElementById('mw-pages');
if (!div)
{
start = 0;
div = document.getElementById('mw-category-media');
if (!div)
div = document.getElementById('mw-subcategories');
}
if (div)
{
var lks = document.getElementsByTagName('a');
var count = 0;
var hrefs = [];
var max_to_open = 10;
if (mw.config.get('wgPageName').indexOf('Category:Candidates_for_speedy_deletion_as_empty_categories') == 0)
max_to_open = 5;
for (var i = 0; i < lks.length; ++i)
{
for (var p = lks[i]; p; p = p.parentNode)
if (p == div
&& lks[i].firstChild.nodeValue != 'next page'
&& lks[i].firstChild.nodeValue != 'previous page')
{
++count;
if (count != start)
hrefs[hrefs.length] = lks[i].href;
break;
}
if (count == max_to_open + start)
break;
}
if (count > start)
{
count -= start;
var s = "";
for (var j = 0; j < count; ++j)
s += 'window.open("' + hrefs[j] + '", "_blank");';
var newnode = document.createElement("a");
newnode.setAttribute("onClick", s);
newnode.setAttribute("href", "#");
newnode.appendChild(document.createTextNode('open'+count));
div.insertBefore(newnode, div.firstChild.nextSibling.nextSibling);
}
}
}
}
function do_onload()
{
fix_watch_links();
add_open10();
cesarb_fixDiffOverflowLoadListener();
morelinks();
move_notifications_to_bottom();
current_time_in_footer();
var pagename = mw.config.get('wgPageName');
var action = mw.config.get('wgAction');
if (pagename == 'Special:Watchlist')
addahah();
else if (pagename.indexOf('Special:RecentChangesLinked/') == 0)
fix_relatedchanges();
else if (pagename.indexOf('Special:WhatLinksHere/') == 0)
add_g8redir_links();
else if (action == 'delete')
expand_delete_dropdown_etc();
var sum = document.getElementById("wpSummary");
if (sum)
sum.style.height = "18px";
}
$(do_onload);
// From [[User:Equazcion/SkipFileWizard.js]]
$('a.new[href*="wpDestFile"]').attr('href', function(index, value)
{
var fileTitle = mw.util.getParamValue('wpDestFile', value);
var fileName = mw.config.get('wgFormattedNamespaces')[6] + ':' + fileTitle;
var params =
{
action: 'edit',
redlink: 1
};
return mw.util.getUrl(fileName, params);
});
// Run styling changes both immediately (in an attempt to prevent [[FOUC]]) and when dom is complete (to be sure it affects all entities)
function manipulate_styling()
{
// Make ffd notices more noticeable so I stop overlooking them when deleting orphaned images
$('table.imbox-delete:has(a[href="/wiki/Wikipedia:Files_for_discussion"])').each(function(){$(this).css("background-color", "red");});
// remove ugly styles from buttons:
$(".mw-ui-button").removeClass("mw-ui-button");
$(".oo-ui-buttonInputWidget").removeClass("oo-ui-buttonInputWidget");
$(".oo-ui-buttonElement-button").removeClass("oo-ui-buttonElement-button");
// and dropdowns
$(".oo-ui-indicator-down").removeClass("oo-ui-indicator-down");
// and checkboxes:
$(".oo-ui-checkboxInputWidget").removeClass("oo-ui-checkboxInputWidget");
// and input fields:
$(".oo-ui-inputWidget").removeClass("oo-ui-inputWidget");
$(".oo-ui-inputWidget-input").removeClass("oo-ui-inputWidget-input");
$(".oo-ui-textInputWidget").removeClass("oo-ui-textInputWidget");
$(".oo-ui-textInputWidget-type-text").removeClass("oo-ui-textInputWidget-type-text");
$(".oo-ui-textInputWidget-php").removeClass("oo-ui-textInputWidget-php");
// remove inflated field margins:
$(".oo-ui-fieldLayout-header").removeClass("oo-ui-fieldLayout-header");
}
manipulate_styling();
function manipulate_styling2()
{
manipulate_styling();
setTimeout(manipulate_styling, 250);
}
$(manipulate_styling2);
//</nowiki>