User:Animum/Sandbox: Difference between revisions

Content deleted Content added
Animum (talk | contribs)
m Feh
m Replaced deprecated <source> tags with <syntaxhighlight> (via WP:JWB)
 
(32 intermediate revisions by 2 users not shown)
Line 1:
<syntaxhighlight lang="JavaScript">
 
if(wgCanonicalSpecialPageName == "Contributions" && document.title.indexOf("for") != -1 && wgEnableAPI) {
<center>
var li_list = document.evaluate('//div[@id="bodyContent"]//ul/li[contains(span[@class="mw-uctop"], "(top)")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); //Lists all of the contributions that are the most recent edits on a page.
{{col-begin|width=50%}}
for(i=0;i<li_list.snapshotLength;i++) {
{{col-2}}
var li = li_list.snapshotItem(i);
<poem>
var href = document.evaluate('a[1]/@href', li, null, XPathResult.STRING_TYPE, null).stringValue;
Gaily bedight,
var oldid = href.split("&oldid=")[1].split("&")[0];
A gallant knight,
var article = href.split("?title=")[1].split("&")[0];
In sunshine and in shadow,
var req = sajax_init_object();
Had journeyed long,
req.open("GET", wgScriptPath + "/api.php?format=json&action=query&prop=revisions&rvlimit=2&rvstartid=" + oldid + "&titles=" + article, false);
Singing a song,
In search of Eldorado req.send(null);
var info = formatResponse(eval("(" + req.responseText + ")"));
 
if(info.revisions) {
But he grew old,
if(info.revisions[1]) {
This knight so bold,
var oldrev = info.revisions[1].revid;
And o'er his heart a shadow,
var link = makeLink("red", wgScript + "?title=" + article + "&action=edit&oldid=" + oldrev + "&script=rv", "revert");
Fell as he found,
li.appendChild(link);
No spot of ground,
That looked like Eldorado. }
}
 
}
And, as his strength,
}
Failed him at length,
</syntaxhighlight>
He met a pilgrim shadow;
"Shadow," said he,
"Where can it be,
This land of Eldorado?"
 
"Over the mountains
Of the moon,
Down the Valley of the Shadow,
Ride, boldly ride,"
The shade replied,
"If you seek for Eldorado!"
</poem>
{{col-2}}
[[File:Edgar Allan Poe portrait B.jpg]]
{{col-end}}
</center>