Revision as of 17:51, 22 February 2020 view sourceCryptic (talk | contribs)Administrators41,692 edits Run styling changes both immediately (in an attempt to prevent FOUC) and when dom is complete (to be sure it affects all entities)← Previous edit |
Latest revision as of 17:55, 17 December 2024 view source Cryptic (talk | contribs)Administrators41,692 editsm ) |
(41 intermediate revisions by the same user not shown) |
Line 76: |
Line 76: |
|
|
|
|
|
// Add links for Logs, Current version, Enable rollback. |
|
// 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. |
|
// 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 there's a template providing a default delete reason, display that in a delete link at the bottom, retaining the no-reason delete link. |
Line 82: |
Line 84: |
|
function morelinks() |
|
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/, 'Misplaced Pages'); // 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("/search/?title=" + encodeURIComponent('Special:Contributions/' + basetitle), |
|
|
'Contribs', parent, watch.nextSibling); |
|
|
pipe(parent, null, watch.nextSibling); |
|
|
addexplicitlink("/search/?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("/search/?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 = "/search/?title=" + encodeURIComponent(title); |
|
|
var txt = lk.firstChild; |
|
|
if (txt.nodeName == '#text') |
|
|
txt.nodeValue = 'Article'; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
var enable_rollback_txt = "var head=document.getElementsByTagName('head');" |
|
var enable_rollback_txt = "var head=document.getElementsByTagName('head');" |
|
+ "var style=document.createElement('style');" |
|
+ "var style=document.createElement('style');" |
Line 90: |
Line 151: |
|
// If there's a protect link, add link for Logs and Current version. |
|
// If there's a protect link, add link for Logs and Current version. |
|
// Always add a link for Enable rollback. |
|
// Always add a link for Enable rollback. |
|
var protect = document.getElementById("cb-ca-unprotect"); |
|
var protect = document.getElementById("ca-cb-unprotect"); |
|
if (!protect) |
|
if (!protect) |
|
protect = document.getElementById("cb-ca-protect"); |
|
protect = document.getElementById("ca-cb-protect"); |
|
if (protect) |
|
if (protect) |
|
{ |
|
{ |
|
var parent = protect.parentNode; |
|
var parent = protect.parentNode; |
|
|
|
|
|
|
pipe(parent, null, protect); |
|
addexplicitlink("/search/?title=Special:Log&page=" + encodeURIComponent(mw.config.get('wgPageName')), |
|
addexplicitlink("/search/?title=Special:Log&page=" + encodeURIComponent(mw.config.get('wgPageName')), |
|
'Logs', parent, protect); |
|
'Logs', parent, protect); |
|
pipe(parent, null, protect); |
|
|
|
|
|
|
|
pipe(parent, null, protect); |
|
addexplicitlink("/search/?title=" + encodeURIComponent(mw.config.get('wgPageName')), |
|
addexplicitlink("/search/?title=" + encodeURIComponent(mw.config.get('wgPageName')), |
|
'Curr', parent, protect); |
|
'Curr', parent, protect); |
|
|
|
|
pipe(parent, null, protect); |
|
pipe(parent, null, protect); |
|
|
|
|
addlink_onclick(enable_rollback_txt, 'Enable rollback', parent, protect); |
|
addlink_onclick(enable_rollback_txt, 'Enable rollback', parent, protect); |
|
pipe(parent, null, protect); |
|
|
} |
|
} |
|
else |
|
else |
|
{ |
|
{ |
|
var parent = document.getElementById("searchform-footer").parentNode; |
|
var parent = document.getElementById("searchform-footer").parentNode; |
|
|
|
|
pipe(parent); |
|
|
addlink_onclick(enable_rollback_txt, 'Enable rollback', parent); |
|
addlink_onclick(enable_rollback_txt, 'Enable rollback', parent); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
var del = document.getElementById("cb-ca-undelete"); |
|
var del = document.getElementById("ca-cb-undelete"); |
|
if (!del) |
|
if (!del) |
|
{ |
|
{ |
|
del = document.getElementById("cb-ca-delete"); |
|
del = document.getElementById("ca-cb-delete"); |
|
if (del) |
|
if (del) |
|
{ |
|
{ |
Line 160: |
Line 219: |
|
delete_reason += " to ]"; |
|
delete_reason += " to ]"; |
|
break; |
|
break; |
|
|
} |
|
|
} |
|
|
else if (node.tagName == 'P' && node.firstChild) |
|
|
{ |
|
|
var n = node.firstChild; |
|
|
if (n.textContent && n.textContent.match(/^\s*#redirect\s*$/i)) |
|
|
{ |
|
|
n = n.nextSibling; |
|
|
if (n.tagName == 'A') |
|
|
{ |
|
|
delete_reason += " to ]"; |
|
|
break; |
|
|
} |
|
} |
|
} |
|
} |
|
} |
Line 185: |
Line 257: |
|
&& node.firstChild.nextSibling.firstChild.nodeName == '#text' |
|
&& node.firstChild.nextSibling.firstChild.nodeName == '#text' |
|
&& node.firstChild.nextSibling.firstChild.nodeValue.match(/^redirect *$/i) |
|
&& node.firstChild.nextSibling.firstChild.nodeValue.match(/^redirect *$/i) |
|
&& node.firstChild.nextSibling.firstChild.nextSibling.tagName == 'A' |
|
&& node.firstChild.nextSibling.firstChild.nextSibling.tagName == 'A') |
|
&& node.firstChild.nextSibling.firstChild.nextSibling.className == 'new') |
|
node = node.firstChild.nextSibling.firstChild.nextSibling; |
|
node = node.firstChild.nextSibling.firstChild.nextSibling.firstChild; |
|
|
else if (node.tagName == 'DIV' |
|
else if (node.tagName == 'DIV' |
|
&& node.className == 'redirectMsg' |
|
&& node.className == 'redirectMsg' |
Line 196: |
Line 267: |
|
&& node.firstElementChild.nextElementSibling.firstChild.tagName == 'LI' |
|
&& node.firstElementChild.nextElementSibling.firstChild.tagName == 'LI' |
|
&& node.firstElementChild.nextElementSibling.firstChild.firstChild |
|
&& node.firstElementChild.nextElementSibling.firstChild.firstChild |
|
&& node.firstElementChild.nextElementSibling.firstChild.firstChild.tagName == 'A' |
|
&& node.firstElementChild.nextElementSibling.firstChild.firstChild.tagName == 'A') |
|
&& node.firstElementChild.nextElementSibling.firstChild.firstChild.className == 'new') |
|
node = node.firstElementChild.nextElementSibling.firstChild.firstChild; |
|
node = node.firstElementChild.nextElementSibling.firstChild.firstChild.firstChild; |
|
|
else |
|
else |
|
continue; |
|
continue; |
|
|
|
|
|
delete_reason = "]: Redirect to a deleted or nonexistent page: ]"; |
|
if (node.className == 'new') |
|
|
delete_reason = "]: Redirect to a deleted or nonexistent page: ]"; |
|
|
else if (node.firstChild.nodeValue.match(/^(Talk|(Draft|User)(talk)?):/i)) |
|
|
delete_reason = "]: ] from mainspace to ]"; |
|
|
else |
|
|
break; |
|
|
|
|
|
addexplicitlink(del.firstChild.href + "&wpReason=" + encodeURIComponent(delete_reason), |
|
addexplicitlink(del.firstChild.href + "&wpReason=" + encodeURIComponent(delete_reason), |
Line 224: |
Line 299: |
|
|
|
|
|
// If a template, wikilink, or external link appears in a diff, make it clickable |
|
// If a template, wikilink, or external link appears in a diff, make it clickable |
|
function link_links_in_diffs() |
|
function link_links_dim_refs_in_diffs() |
|
{ |
|
{ |
|
var tds = document.getElementsByTagName('td'); |
|
var tds = document.getElementsByTagName('td'); |
|
|
|
|
|
for (var i = 0; i < tds.length; ++i) |
|
for (var i = 0; i < tds.length; ++i) |
|
|
{ |
|
if (tds.className == 'diff-deletedline' || tds.className == 'diff-addedline' || tds.className == 'diff-context') |
|
|
|
var classes = tds.className.split(' '); |
|
{ |
|
|
var txt = tds.innerHTML.replace(new RegExp('(\\ <]+)( ])', '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/$1">$1</a>$2'); |
|
|
txt = txt.replace(new RegExp('\\{\\{(+)()', 'g'), '{{<a href="https://en.wikipedia.org/Template:$1">$1</a>$2'); |
|
|
txt = txt.replace(new RegExp('(\\|<]+)(|])', 'g'), '$1<a href="https://en.wikipedia.org/$2">$2</a>$3'); |
|
|
tds.innerHTML = txt.replace(new RegExp('(\\|]*<SPAN class="*">:?)(|<]+)(</SPAN>|])', 'gi'), '$1<a href="https://en.wikipedia.org/$2">$2</a>$3'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
for (var j = 0; j < classes.length; j++) |
|
|
if (classes == 'diff-context' || classes == 'diff-addedline' || classes == 'diff-deletedline') |
|
|
{ |
|
|
var txt = tds.innerHTML; |
|
|
|
|
|
|
if (txt.indexOf("&@<my") < 0) |
|
// If a ref appears in a diff page but isn't changed, dim it out and make it smaller so it doesn't distract from text |
|
|
|
{ |
|
function dim_refs_in_diffs() |
|
|
|
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>'); |
|
var tds = document.getElementsByTagName('td'); |
|
|
|
txt = txt.replace(new RegExp('&@<mybra;', 'g'), '<'); |
|
|
txt = txt.replace(new RegExp('&@<myket;', 'g'), '>'); |
|
|
} |
|
|
|
|
|
|
txt = txt.replace(new RegExp('(\\ <]+)( ])', 'gi'), '$1<a href="$2">$2</a>$3'); |
|
for (var i = 0; i < tds.length; ++i) |
|
|
|
txt = txt.replace(new RegExp('\\{\\{((?:talk|user|wikipedia|image|mediawiki|template|help|category|portal)(?:talk)?:+)()', 'gi'), '{{<a href="https://en.wikipedia.org/$1">$1</a>$2'); |
|
if (tds.className == 'diff-deletedline' || tds.className == 'diff-addedline' || tds.className == 'diff-context') |
|
|
|
txt = txt.replace(new RegExp('\\{\\{(\\s*(?:tlsp|lts|tl?)\\s*\\|\\s*|\\s*)(+)()', 'g'), '{{$1<a href="https://en.wikipedia.org/Template:$2">$2</a>$3'); |
|
{ |
|
|
|
function enwikilk(match, p1, p2, p3){ return p1 + '<a href="https://en.wikipedia.org/' + p2.replace(/ +/g, '_') + '">' + p2 + '</a>' + p3; }; |
|
var txt = tds.innerHTML; |
|
|
|
txt = txt.replace(new RegExp('(\\|<]+)(|])', 'g'), enwikilk); |
|
if (txt.indexOf("&@my") != -1) |
|
|
|
txt = txt.replace(new RegExp('(\\|]*<SPAN class="*">:?)(|<]+)(</SPAN>|])', 'gi'), enwikilk); |
|
continue; |
|
|
txt = txt.replace(new RegExp('<(/?(del|ins)( class="*")?)>', 'g'), '&@mybra;$1&@myket;'); |
|
txt = txt.replace(new RegExp('\\b(url\\s*=\\s*)(https?://|{} <>]+?)(\\s*(\\||\\}\\}))', 'gi'), '$1<a href="$2">$2</a>$3'); |
|
|
|
|
txt = txt.replace(new RegExp('(<ref*?(/>|\\bref\\b( *>)?))', 'gi'), '<span style="color:#cccccc !important; font-size:x-small !important;">$1</span>'); |
|
|
|
tds.innerHTML = txt; |
|
txt = txt.replace(new RegExp('(url *= *)(http:\\/\\/\\|\\} <]+?)( *(\\||\\}\\}|</div>$))', 'gi'), '$1<a href="$2">$2</a>$3'); |
|
|
txt = txt.replace(new RegExp('&@mybra;', 'g'), '<'); |
|
break; |
|
|
} |
|
txt = txt.replace(new RegExp('&@myket;', 'g'), '>'); |
|
|
|
} |
|
tds.innerHTML = txt; |
|
|
} |
|
|
} |
|
} |
|
|
|
|
Line 305: |
Line 379: |
|
{ |
|
{ |
|
cesarb_fixDiffOverflowTable(table); |
|
cesarb_fixDiffOverflowTable(table); |
|
dim_refs_in_diffs(); |
|
link_links_dim_refs_in_diffs(); |
|
link_links_in_diffs(); |
|
|
break loop; |
|
break loop; |
|
} |
|
} |
Line 334: |
Line 407: |
|
* the same place. |
|
* the same place. |
|
* 3. Whenever an item is selected from the dropdownlist, immediately insert it |
|
* 3. Whenever an item is selected from the dropdownlist, immediately insert it |
|
* into the "Additional reasons" input for further editing, then reselect |
|
* into the "Additional reasons" input for further editing, then reselect the |
|
* "Other reason". |
|
* first option. |
|
* 4. Add a button to clear the reason line. |
|
* 4. Add a button to clear the reason line. |
|
* 5. If a preset deletion reason, or adding reasons from the dropdownlist, |
|
* 5. If a preset deletion reason, or adding reasons from the dropdownlist, |
Line 352: |
Line 425: |
|
if (delreason) |
|
if (delreason) |
|
{ |
|
{ |
|
var p = delreason.parentNode; |
|
var p = delreason.parentNode; // "You are about to delete ] along with all of its history. Please:" |
|
var ul = p.previousElementSibling; |
|
var ul = p.previousElementSibling; // "*Confirm...", "*Review...", "*Check...", "*Provide..." |
|
if (ul.nodeName == 'UL') |
|
if (ul.nodeName == 'UL') |
|
{ |
|
{ |
|
p = ul.previousElementSibling; |
|
p = ul.previousElementSibling; |
|
|
var div = p.previousElementSibling; // "WARNING: Other pages link to..." Duh. *Always* present, because of the user pages that uselessly transclude ]. |
|
if (p.nodeName == 'P') |
|
if (p.nodeName == 'P') |
|
{ |
|
{ |
Line 362: |
Line 436: |
|
ul.parentNode.removeChild(ul); |
|
ul.parentNode.removeChild(ul); |
|
} |
|
} |
|
|
if (div && div.nodeName == 'DIV') |
|
|
div.parentNode.removeChild(div); |
|
} |
|
} |
|
} |
|
} |
Line 368: |
Line 444: |
|
//$(".oo-ui-dropdownInputWidget").removeClass("oo-ui-dropdownInputWidget"); |
|
//$(".oo-ui-dropdownInputWidget").removeClass("oo-ui-dropdownInputWidget"); |
|
//$(".oo-ui-dropdownInputWidget-php").removeClass("oo-ui-dropdownInputWidget-php"); |
|
//$(".oo-ui-dropdownInputWidget-php").removeClass("oo-ui-dropdownInputWidget-php"); |
|
|
|
|
/* Expand the whole list. We actually create a new one, copy the elements |
|
/* 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 the old one into there, and hide the old one, to minimize interference |
|
* from hostile developers. */ |
|
* from hostile developers. */ |
|
var nsel = document.createElement('select'); |
|
var nsel = document.createElement('select'); |
|
|
|
|
var len = 0; |
|
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'); |
|
var optgroups = reasons.getElementsByTagName('optgroup'); |
|
for (var i = 0; i < optgroups.length; ++i) |
|
for (var i = 0; i < optgroups.length; ++i) |
|
{ |
|
{ |
|
var og = optgroups; |
|
var og = optgroups; |
|
/* Skip the oversighter-only section (how come it's displayed to |
|
// Skip the talk section (we put it with the primary g8) |
|
|
if (!og.label.match(/talk pages/i)) |
|
* everyone?) - obviously this is very fragile */ |
|
|
|
{ |
|
if (og.label != "FOR USE BY OVERSIGHTERS ONLY, when suppressing privacy and defamation:") |
|
|
|
var nog = document.createElement('optgroup'); |
|
{ |
|
|
|
nog.label = og.label; |
|
var nog = document.createElement('optgroup'); |
|
|
|
nsel.appendChild(nog); |
|
nog.label = og.label; |
|
|
|
++len; |
|
nsel.appendChild(nog); |
|
|
++len; |
|
|
|
|
|
|
var options = og.getElementsByTagName('option'); |
|
var options = og.getElementsByTagName('option'); |
|
for (var j = 0; j < options.length; ++j) |
|
for (var j = 0; j < options.length; ++j) |
|
{ |
|
{ |
|
var txt = options.value; |
|
var txt = options.value; |
|
/* Entirely the wrong place to try to teach admins which articles |
|
|
* can be A7d; the text for U5 is vague and antagonistic; and add |
|
|
* same advice to G7 and U1 that db-g7 and db-u1 do */ |
|
|
if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/ \(indiv.+/, ''); |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/Misuse of Misplaced Pages as a web host/, "Writings unrelated to Wikimedia's goals, by a user with few or no edits outside of userspace"); |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/Cross-\\] \\]/, "]"); |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt + " – If you wish to retrieve it, please see ]"; |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/to retrieve it, see/, "If you wish to retrieve it, please see"); |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/ or \\] submission/, ''); |
|
|
|
|
|
|
|
// enable G1 and G2 in all namespaces, to be used in extremis |
|
var nop = document.createElement('option'); |
|
|
|
if (txt.match(/^\\].+/)) |
|
nop.value = txt; |
|
|
|
g1_seen = 1; |
|
nop.appendChild(document.createTextNode(txt)); |
|
|
|
else if (txt.match(/^\\].+/) && !g1_seen) |
|
nog.appendChild(nop); |
|
|
++len; |
|
{ |
|
|
len += add_option(nog, "]: ], meaningless, or incomprehensible"); |
|
} |
|
|
|
len += add_option(nog, "]: 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(/^\\].+/)) |
|
|
len += add_option(nog, "]: Talk page of a nonexistent or deleted page"); |
|
|
|
|
|
// essentially all G13s are drafts now, not afc-templated user subpages |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/ or \\] submission/, ''); |
|
|
|
|
|
// Entirely the wrong place to try to teach admins which articles can be A7d |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/ \(indiv.+/, ''); |
|
|
|
|
|
// the text for U5 is vague and antagonistic |
|
|
else if (txt.match(/^\\].+/)) |
|
|
txt = txt.replace(/Misuse of Misplaced Pages 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(/^\\].+/)) |
|
|
txt = txt.replace(/Cross-\\] \\]/, "]"); |
|
|
|
|
|
len += add_option(nog, txt); |
|
|
} |
|
|
} |
|
} |
|
} |
|
|
|
|
Line 423: |
Line 522: |
|
|
|
|
|
// Move the additional reason input, watch checkbox, and delete button above it, so they're always in the same place |
|
// Move the additional reason input, watch checkbox, and delete button above it, so they're always in the same place |
|
var reasonrow; |
|
var reason; |
|
var deletebutton; |
|
var deletebutton; |
|
var imgtable = document.getElementById('mw-img-deleteconfirm-table'); |
|
var imgtable = document.getElementById('mw-img-deleteconfirm-table'); |
|
if (imgtable) |
|
if (imgtable) |
|
{ |
|
{ |
|
reasonrow = imgtable.getElementsByTagName('tr'); |
|
reason = imgtable.getElementsByTagName('tr'); // probably not, but I'll worry about it the next time I delete an image |
|
|
reason.id = 'actual_reason'; |
|
deletebutton = imgtable.getElementsByTagName('tr').getElementsByClassName('mw-submit').firstElementChild; |
|
deletebutton = imgtable.getElementsByTagName('tr').getElementsByClassName('mw-submit').firstElementChild; |
|
} |
|
} |
|
else |
|
else |
|
{ |
|
{ |
|
reasonrow = document.getElementById('wpReason'); |
|
reason = document.getElementById('wpReason').firstChild; |
|
|
reason.id = 'actual_reason'; |
|
deletebutton = document.getElementById('wpConfirmB'); |
|
deletebutton = document.getElementById('wpConfirmB'); |
|
} |
|
} |
Line 440: |
Line 541: |
|
spacer.style = "margin-left:1em"; |
|
spacer.style = "margin-left:1em"; |
|
|
|
|
|
var watch = document.getElementById('wpWatch').parentNode.parentNode; |
|
var watch = document.getElementById('wpWatch').parentNode; |
|
var watchlabel = watch.nextElementSibling; |
|
var watchlabel = watch.nextElementSibling; |
|
|
|
|
|
var clearbutton = makebutton('clear', |
|
var clearbutton = makebutton('clear', |
|
'var reason = document.getElementById("wpReason");' |
|
'var reason = document.getElementById("actual_reason");' |
|
+ 'reason.value="";' |
|
+ 'reason.value="";' |
|
+ 'reason.style="background-color:white";' |
|
+ 'reason.style="background-color:white";' |
Line 455: |
Line 556: |
|
div.appendChild(watchlabel); |
|
div.appendChild(watchlabel); |
|
div.appendChild(clearbutton); |
|
div.appendChild(clearbutton); |
|
div.appendChild(reasonrow); |
|
div.appendChild(reason); |
|
div.appendChild(nsel); |
|
div.appendChild(nsel); |
|
|
|
|
|
for (var n = root.firstChild; n; n = n.nextChild) |
|
for (var n = root.firstChild; n; n = n.nextSibling) |
|
n.style.display='none'; |
|
n.style.display='none'; |
|
|
|
|
Line 468: |
Line 569: |
|
nsel.onchange = function() |
|
nsel.onchange = function() |
|
{ |
|
{ |
|
var reason = document.getElementById('wpReason'); |
|
var reason = document.getElementById('actual_reason'); |
|
var sel = this.selectedIndex; |
|
var sel = this.selectedIndex; |
|
if (sel != 0) // 0 is "Other reason" |
|
if (sel != 0) // 0 is "Other reason" |
Line 487: |
Line 588: |
|
/* And set initial value of wpWatch for c1/g7/g8/g13/u1. If initially g8, and |
|
/* 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. */ |
|
* deleting a talk page, then don't change watched status. */ |
|
var reasonv = document.getElementById('wpReason').value; |
|
var reasonv = document.getElementById('actual_reason').value; |
|
if (reasonv.match(/^\alk page.*of a (deleted|non.?exist)/)) |
|
if (reasonv.match(/^\alk page.*of a (deleted|non.?exist)/)) |
|
document.getElementById('wpWatch').checked = !!document.getElementById("cb-ca-unwatch"); |
|
document.getElementById('wpWatch').firstChild.checked = !!document.getElementById("ca-cb-unwatch"); |
|
else |
|
else |
|
document.getElementById('wpWatch').checked = should_watch(reasonv); |
|
document.getElementById('wpWatch').firstChild.checked = should_watch(reasonv); |
|
|
|
|
|
/* Whenever anything forces the length of the additional-reasons input above |
|
/* Whenever anything forces the length of the additional-reasons input above |
|
* its max, change its background color */ |
|
* its max, change its background color */ |
|
var reason = document.getElementById('wpReason'); |
|
|
reason.oninput = function(){ check_reason_length(this); }; |
|
reason.oninput = function(){ check_reason_length(this); }; |
|
|
|
|
Line 528: |
Line 628: |
|
} |
|
} |
|
|
|
|
|
// Add "ahah" links to watchlist - "all histories above here" |
|
// 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() |
|
function addahah() |
|
{ |
|
{ |
Line 536: |
Line 637: |
|
{ |
|
{ |
|
if (as.innerHTML == 'diff') |
|
if (as.innerHTML == 'diff') |
|
as.href = as.href.replace(/&curid=+/, ''); |
|
as.href = as.href.replace(/&curid=+&diff=(+)&oldid=+/, '&diff=prev&oldid=$1'); |
|
else if (as.innerHTML == 'hist') |
|
else if (as.innerHTML == 'hist') |
|
{ |
|
{ |
Line 580: |
Line 681: |
|
for (var li = wlh.firstChild; li; li = li.nextSibling) |
|
for (var li = wlh.firstChild; li; li = li.nextSibling) |
|
if (li.firstChild |
|
if (li.firstChild |
|
&& li.firstChild.href |
|
&& li.firstChild.firstChild |
|
&& li.firstChild.href.indexOf('&redirect=no') != -1 |
|
&& li.firstChild.firstChild.href |
|
&& li.firstChild.nextSibling.nodeValue.indexOf('(redirect page)') != -1) |
|
&& 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) |
|
if (!tgt) |
|
tgt = "&action=delete&wpReason=" |
|
tgt = "&action=delete&wpReason=" |
|
+ encodeURIComponent("]: Redirect to a deleted or nonexistent page: ]").replace('%20', '+', 'g') |
|
+ encodeURIComponent("]: Redirect to a deleted or nonexistent page: ]").replace('_', '+', 'g').replace('%20', '+', 'g') |
|
+ "&action=delete"; |
|
+ "&action=delete"; |
|
|
|
|
|
var newnode = addexplicitlink(li.firstChild.href + tgt, 'delete G8'); |
|
var newnode = addexplicitlink(li.firstChild.firstChild.href + tgt, 'delete G8'); |
|
// Place on the same line, whether there are incoming links to this redirect or not |
|
// Place on the same line, whether there are incoming links to this redirect or not |
|
var x; |
|
var x; |
Line 639: |
Line 742: |
|
if (footer) |
|
if (footer) |
|
for (var n = footer.firstChild; n; n = n.nextSibling) |
|
for (var n = footer.firstChild; n; n = n.nextSibling) |
|
|
{ |
|
if (n.tagName == 'A' && n.href.indexOf('Misplaced Pages:About') > 0) |
|
|
{ |
|
if (n.tagName == 'BR') |
|
var span = document.createElement('span'); |
|
n.style.display = 'none'; |
|
|
else if (n.tagName == 'UL') |
|
span.appendChild(document.createTextNode(new Date().toUTCString())); |
|
|
span.setAttribute('onClick', 'this.firstChild.textContent = new Date().toUTCString();'); |
|
for (var nn = n.firstChild; nn; nn = nn.nextSibling) |
|
|
if (nn.firstChild && nn.firstChild.tagName == 'A' && nn.firstChild.href.indexOf('Misplaced Pages:About') > 0) |
|
footer.insertBefore(span, n); |
|
|
footer.removeChild(n); |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Add a "reduced" button when editing File: pages to edit away ] |
|
|
function add_reduced_button() |
|
|
{ |
|
|
if (document.editform.wpTextbox1.value.match(/\{\{(on-free reduced|rphaned non-free revisions) *(\|*)*\}\}/)) |
|
|
{ |
|
|
var button = makebutton('reduced', |
|
|
'var old = document.editform.wpTextbox1.value;' |
|
|
+ 'var s = old;' |
|
|
+ 's = s.replace(/^*\\{\\{(on-free reduced|rphaned non-free revisions) *(\\|*)*\\}\\}*/g, "");' |
|
|
+ 's = s.replace(/^\\{\\{(on-free reduced|rphaned non-free revisions) *(\\|*)*\\}\\}?/gm, "");' |
|
|
+ 's = s.replace(/^\\{\\{(on-free reduced|rphaned non-free revisions) *(\\|*)*\\}\\}/g, "");' |
|
|
+ 'if (s != old)' |
|
|
+ ' {' |
|
|
+ ' document.editform.wpTextbox1.value = s;' |
|
|
+ ' document.editform.wpSummary.value = "Previous version removed";' |
|
|
+ ' document.getElementById("wpWatchthis").checked = 0;' |
|
|
+ ' document.editform.wpSummary.focus();' |
|
|
+ ' }'); |
|
|
var first = document.getElementById('firstHeading'); |
|
|
first.appendChild(button, first.nextSibling); |
|
|
var button2 = makebutton('reducemore', |
|
|
'var old = document.editform.wpTextbox1.value;' |
|
|
+ 'var s = old;' |
|
|
+ 's = s.replace(/^*\\{\\{(on-free reduced|rphaned non-free revisions) *(\\|*)*\\}\\}*/g, "");' |
|
|
+ 's = s.replace(/^\\{\\{(on-free reduced|rphaned non-free revisions) *(\\|*)*\\}\\}?/gm, "");' |
|
|
+ 's = s.replace(/^\\{\\{(on-free reduced|rphaned non-free revisions) *(\\|*)*\\}\\}/g, "");' |
|
|
+ 's = "{{non-free reduce}}\\n" + s;' |
|
|
+ 'if (s != old)' |
|
|
+ ' {' |
|
|
+ ' document.editform.wpTextbox1.value = s;' |
|
|
+ ' document.editform.wpSummary.value = "Previous version removed; but current version needs size reduction per ]";' |
|
|
+ ' document.getElementById("wpWatchthis").checked = 1;' |
|
|
+ ' document.editform.wpSummary.focus();' |
|
|
+ ' }'); |
|
|
first.appendChild(button2, first.nextSibling.nextSibling); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Add a link to delete all but the current revision of a file |
|
|
function add_del_prev_revisions() |
|
|
{ |
|
|
var filehistory = document.getElementById("filehistory"); |
|
|
if (!filehistory) |
|
|
return; |
|
|
|
|
|
var target = ''; |
|
|
var ids = ''; |
|
|
|
|
|
var spans = document.getElementsByTagName("span"); |
|
|
for (var i = 0; i < spans.length; ++i) |
|
|
{ |
|
|
var span = spans; |
|
|
var classes = span.className.split(' '); |
|
|
for (var j = 0; j < classes.length; ++j) |
|
|
if (classes == 'mw-revdelundel-link') |
|
|
{ |
|
|
var a = span.firstChild.nextSibling; |
|
|
if (a && a.title == 'Special:RevisionDelete') |
|
|
{ |
|
{ |
|
var matches = a.href.match("&ids=(+)$"); |
|
var span = document.createElement('span'); |
|
if (matches) |
|
span.appendChild(document.createTextNode(new Date().toUTCString())); |
|
|
span.setAttribute('onClick', 'this.firstChild.textContent = new Date().toUTCString();'); |
|
{ |
|
|
if (target == '') |
|
var olda = nn.firstChild; |
|
{ |
|
nn.insertBefore(span, olda); |
|
target = a.href; |
|
nn.removeChild(olda); |
|
ids = matches; |
|
return; |
|
} |
|
|
else |
|
|
{ |
|
|
target += ','; |
|
|
target += matches; |
|
|
ids += ','; |
|
|
ids += matches; |
|
|
} |
|
|
} |
|
|
} |
|
} |
|
break; |
|
} |
|
} |
|
|
} |
|
|
|
|
|
if (target != '') |
|
|
{ |
|
|
pipe(filehistory, ' - '); |
|
|
addexplicitlink(target + '&wpReason=' + encodeURIComponent(']: Orphaned revision of nonfree media'), |
|
|
'Delete revisions ' + ids, |
|
|
filehistory); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Autoselect "delete file content" at ] if we preselected the deleting-orphan-revisions reason |
|
|
function revision_delete_stuff() |
|
|
{ |
|
|
var reason = document.getElementById('wpReason'); |
|
|
if (reason && reason.value == ']: Orphaned revision of nonfree media') |
|
|
{ |
|
|
var radios = document.getElementsByName('wpHidePrimary'); |
|
|
if (radios.length == 1) // one revision |
|
|
radios.checked = 1; |
|
|
else if (radios.length == 3) // two or more revisions |
|
|
radios.checked = 1; |
|
|
reason.focus(); // so I can just hit enter to confirm |
|
|
} |
|
|
|
|
|
// Edit link |
|
|
var n = document.getElementById('firstHeading'); |
|
|
n = n.nextElementSibling.nextElementSibling; |
|
|
var hist = n.firstElementChild.nextElementSibling; |
|
|
if (hist && hist.nodeName == 'A' && hist.href.match(/&action=history$/)) |
|
|
{ |
|
|
pipe(n); |
|
|
addexplicitlink(hist.href.replace(/action=history$/,"action=edit"), 'Edit', n); |
|
|
} |
|
|
} |
|
} |
|
|
|
|
Line 813: |
Line 806: |
|
{ |
|
{ |
|
var watched = false; |
|
var watched = false; |
|
var bot = document.getElementById("cb-ca-watch"); |
|
var bot = document.getElementById("ca-cb-watch"); |
|
if (!bot) |
|
if (!bot) |
|
{ |
|
{ |
|
bot = document.getElementById("cb-ca-unwatch"); |
|
bot = document.getElementById("ca-cb-unwatch"); |
|
if (!bot) |
|
if (!bot) |
|
return; |
|
return; |
Line 854: |
Line 847: |
|
var div = document.getElementById('mw-category-media'); |
|
var div = document.getElementById('mw-category-media'); |
|
if (div) |
|
if (div) |
|
for (var ul = div.firstChild; ul; ul = ul.nextSibling) |
|
for (var ul = div.firstChild; ul; ul = ul.nextSibling) |
|
if (ul.tagName == 'UL' && ul.className.indexOf('mw-gallery-traditional') >= 0) |
|
if (ul.tagName == 'UL' && ul.className.indexOf('mw-gallery-traditional') >= 0) |
|
{ |
|
{ |
|
var count = 0; |
|
var count = 0; |
|
var first = 0; |
|
var first = 0; |
|
for (var node = ul.firstChild; ; node = node.nextSibling) |
|
for (var node = ul.firstChild; ; node = node.nextSibling) |
|
|
{ |
|
{ |
|
|
if (node && node.tagName == 'LI') |
|
if (node && node.tagName == 'LI') |
|
if (++count == 1) |
|
if (++count == 1) |
|
first = node; |
|
first = node; |
|
|
|
|
|
if (count == 11 || (!node && count != 0)) |
|
if (count == 11 || (!node && count != 0)) |
|
{ |
|
{ |
|
var newnode = document.createElement("br"); |
|
var newnode = document.createElement("br"); |
|
ul.insertBefore(newnode, first); |
|
ul.insertBefore(newnode, first); |
|
newnode = document.createElement("a"); |
|
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("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.setAttribute("href", "#"); |
|
newnode.appendChild(document.createTextNode('>>')); |
|
newnode.appendChild(document.createTextNode('>>')); |
|
ul.insertBefore(newnode, first); |
|
ul.insertBefore(newnode, first); |
|
count = 0; |
|
count = 0; |
|
first = 0; |
|
first = 0; |
|
} |
|
} |
|
|
|
|
|
if (!node) |
|
if (!node) |
|
break; |
|
break; |
|
|
} |
|
} |
|
|
} |
|
} |
|
} |
|
} |
|
|
|
|
Line 893: |
Line 886: |
|
var div = document.getElementById('mw-pages'); |
|
var div = document.getElementById('mw-pages'); |
|
if (!div) |
|
if (!div) |
|
|
{ |
|
{ |
|
|
start = 0; |
|
start = 0; |
|
div = document.getElementById('mw-category-media'); |
|
div = document.getElementById('mw-category-media'); |
|
if (!div) |
|
if (!div) |
|
div = document.getElementById('mw-subcategories'); |
|
div = document.getElementById('mw-subcategories'); |
|
|
} |
|
} |
|
|
if (div) |
|
if (div) |
|
|
{ |
|
{ |
|
|
var lks = document.getElementsByTagName('a'); |
|
var lks = document.getElementsByTagName('a'); |
|
var count = 0; |
|
var count = 0; |
|
var hrefs = ; |
|
var hrefs = ; |
|
var max_to_open = 10; |
|
var max_to_open = 10; |
|
if (mw.config.get('wgPageName').indexOf('Category:Candidates_for_speedy_deletion_as_empty_categories') == 0) |
|
if (mw.config.get('wgPageName').indexOf('Category:Candidates_for_speedy_deletion_as_empty_categories') == 0) |
|
max_to_open = 5; |
|
max_to_open = 5; |
|
|
|
|
|
for (var i = 0; i < lks.length; ++i) |
|
for (var i = 0; i < lks.length; ++i) |
|
{ |
|
{ |
|
for (var p = lks; p; p = p.parentNode) |
|
for (var p = lks; p; p = p.parentNode) |
|
if (p == div |
|
if (p == div |
|
&& lks.firstChild.nodeValue != 'next page' |
|
&& lks.firstChild.nodeValue != 'next page' |
|
&& lks.firstChild.nodeValue != 'previous page') |
|
&& lks.firstChild.nodeValue != 'previous page') |
|
|
{ |
|
{ |
|
|
++count; |
|
++count; |
|
if (count != start) |
|
if (count != start) |
|
hrefs = lks.href; |
|
hrefs = lks.href; |
|
break; |
|
break; |
|
|
} |
|
} |
|
|
if (count == max_to_open + start) |
|
if (count == max_to_open + start) |
|
break; |
|
break; |
|
} |
|
} |
|
|
|
|
|
if (count > start) |
|
if (count > start) |
|
{ |
|
{ |
|
count -= start; |
|
count -= start; |
|
var s = ""; |
|
var s = ""; |
|
for (var j = 0; j < count; ++j) |
|
for (var j = 0; j < count; ++j) |
|
s += 'window.open("' + hrefs + '", "_blank");'; |
|
s += 'window.open("' + hrefs + '", "_blank");'; |
|
var newnode = document.createElement("a"); |
|
var newnode = document.createElement("a"); |
|
newnode.setAttribute("onClick", s); |
|
newnode.setAttribute("onClick", s); |
|
newnode.setAttribute("href", "#"); |
|
newnode.setAttribute("href", "#"); |
|
newnode.appendChild(document.createTextNode('open'+count)); |
|
newnode.appendChild(document.createTextNode('open'+count)); |
|
div.insertBefore(newnode, div.firstChild.nextSibling.nextSibling); |
|
div.insertBefore(newnode, div.firstChild.nextSibling.nextSibling); |
|
} |
|
} |
|
|
} |
|
} |
|
|
} |
|
} |
|
} |
|
} |
Line 961: |
Line 954: |
|
else if (action == 'delete') |
|
else if (action == 'delete') |
|
expand_delete_dropdown_etc(); |
|
expand_delete_dropdown_etc(); |
|
|
|
|
// Work ] |
|
|
else if (mw.config.get('wgNamespaceNumber') == 6) // File: |
|
|
{ |
|
|
if (action == 'edit') |
|
|
add_reduced_button(); |
|
|
else |
|
|
add_del_prev_revisions(); |
|
|
} |
|
|
else if (pagename == 'Special:RevisionDelete') |
|
|
revision_delete_stuff(); |
|
|
|
|
|
|
var sum = document.getElementById("wpSummary"); |
|
var sum = document.getElementById("wpSummary"); |
Line 1,016: |
Line 998: |
|
} |
|
} |
|
manipulate_styling(); |
|
manipulate_styling(); |
|
|
function manipulate_styling2() |
|
$(manipulate_styling); |
|
|
|
{ |
|
|
manipulate_styling(); |
|
|
setTimeout(manipulate_styling, 250); |
|
|
} |
|
|
$(manipulate_styling2); |
|
//</nowiki> |
|
//</nowiki> |