-
-
Save gaby-de-wilde/1039169 to your computer and use it in GitHub Desktop.
Patch dinosauric wikipedia software
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Patch dinosauric wikipedia software | |
// @namespace asdfasdfasdfasdfdasf | |
// @description GM_xmlhttpRequest XML | |
// @include http://en.wikipedia.org/w/*action=history* | |
// @include https://en.wikipedia.org/w/*action=history* | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
// Configuration | |
maximumNumberOfItems = 600; // howmany items you want | |
redirect = "yes"; // set this to no if you dont want to be redirected. | |
superSexyMode = "off"; // Optionally move some of the links from the top of the page into a side bar menu. | |
// redirect if maximumNumberOfItems is set lower than the default of 50 | |
if(document.location.href.indexOf('limit=')==-1 && redirect=="yes" && maximumNumberOfItems<50){ | |
document.location.href=document.location.href+"&limit="+maximumNumberOfItems; | |
}else{ | |
allHTMLListItems = document.getElementsByTagName('li'); | |
listOfAlreadyManagedDivs=""; | |
for(listItemPointer=0;listItemPointer<=allHTMLListItems.length;listItemPointer++){ | |
listItemChunks=allHTMLListItems[listItemPointer].innerHTML.split('"'); | |
for(itemChunkPointer=0;itemChunkPointer<=listItemChunks.length;itemChunkPointer++){ | |
if( !isNaN( listItemChunks[itemChunkPointer] ) ){ | |
num=listItemChunks[itemChunkPointer]; | |
if(listOfAlreadyManagedDivs.indexOf(num)==-1){ | |
listOfAlreadyManagedDivs=listOfAlreadyManagedDivs+","+num; | |
GM_xmlhttpRequest({ | |
method: 'GET', | |
url: 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&revids='+num+'&rvdiffto=prev&format=xml', | |
onload: function(response) { | |
var xml = new DOMParser() | |
xml = xml.parseFromString(response.responseText, "text/xml"); | |
unsafeWindow.console.log("The response was: ", xml); | |
x=xml.getElementsByTagName("diff")[0].childNodes[0].nodeValue; | |
targetRev=xml.getElementsByTagName("rev")[0].getAttribute('revid'); | |
finished=0; | |
allHTMLListItems=document.getElementsByTagName('li'); | |
for(listItemPointer=0;listItemPointer<=allHTMLListItems.length;listItemPointer++){ | |
listItemChunks=allHTMLListItems[listItemPointer].innerHTML.split('"'); | |
for(itemChunkPointer=0;itemChunkPointer<=listItemChunks.length;itemChunkPointer++){ | |
if(!isNaN(listItemChunks[itemChunkPointer])){ | |
if( listItemChunks[itemChunkPointer] == targetRev && finished == 0 ){ | |
finished=1; | |
y=allHTMLListItems[listItemPointer].innerHTML; | |
allHTMLListItems[listItemPointer].innerHTML = y+"<hr class=\"ruler\">\ | |
<table width=\"100%\">"+x+"</table>\ | |
\ | |
<style>\ | |
.ruler {border:0;color:#FFDBDB;background-color:#FFDBDB;height:4px;}\ | |
li {margin-left:-25px;}\ | |
li:first-line {font-size:110%;}\ | |
table {font-size:14px;line-height:20px;}\ | |
td {vertical-align:top}\ | |
diff-context {width:45%;}\ | |
.diff-marker {width:1%;}\ | |
.diff-deletedline {width:45%;\ | |
\ | |
/* IE10 Consumer Preview */ \ | |
background-image: -ms-radial-gradient(center, circle farthest-corner, #FFE8E9 0%, #FFFFFF 100%);\ | |
\ | |
/* Mozilla Firefox */ \ | |
background-image: -moz-radial-gradient(center, circle farthest-corner, #FFE8E9 0%, #FFFFFF 100%);\ | |
\ | |
/* Opera */ \ | |
background-image: -o-radial-gradient(center, circle farthest-corner, #FFE8E9 0%, #FFFFFF 100%);\ | |
\ | |
/* Webkit (Safari/Chrome 10) */ \ | |
background-image: -webkit-gradient(radial, center center, 0, center center, 500, color-stop(0, #FFE8E9), color-stop(1, #FFFFFF));\ | |
\ | |
/* Webkit (Chrome 11+) */ \ | |
background-image: -webkit-radial-gradient(center, circle farthest-corner, #FFE8E9 0%, #FFFFFF 100%);\ | |
\ | |
/* W3C Markup, IE10 Release Preview */ \ | |
background-image: radial-gradient(circle farthest-corner at center, #FFE8E9 0%, #FFFFFF 100%);\ | |
}\ | |
.diff-addedline {width:45%;\ | |
\ | |
/* IE10 Consumer Preview */ \ | |
background-image: -ms-radial-gradient(center, circle farthest-corner, #D7F4EC 0%, #FFFFFF 100%);\ | |
\ | |
/* Mozilla Firefox */ \ | |
background-image: -moz-radial-gradient(center, circle farthest-corner, #D7F4EC 0%, #FFFFFF 100%);\ | |
\ | |
/* Opera */ \ | |
background-image: -o-radial-gradient(center, circle farthest-corner, #D7F4EC 0%, #FFFFFF 100%);\ | |
\ | |
/* Webkit (Safari/Chrome 10) */ \ | |
background-image: -webkit-gradient(radial, center center, 0, center center, 500, color-stop(0, #D7F4EC), color-stop(1, #FFFFFF));\ | |
\ | |
/* Webkit (Chrome 11+) */ \ | |
background-image: -webkit-radial-gradient(center, circle farthest-corner, #D7F4EC 0%, #FFFFFF 100%);\ | |
\ | |
/* W3C Markup, IE10 Release Preview */ \ | |
background-image: radial-gradient(circle farthest-corner at center, #D7F4EC 0%, #FFFFFF 100%);\ | |
}\ | |
.diffchange {color:red;}\ | |
.diffchange-inline {color:green;font-weight:bold;}\ | |
.comment {font-size:180%;display:block;background-color:#FFDBDB;line-height:160%; border-radius: 15px;padding-left:7px;border:2px solid #BB7070}\ | |
</style><hr class=\"ruler\">"; | |
} | |
} | |
} | |
} | |
} | |
}); | |
} | |
} | |
} | |
if(listItemPointer>=maximumNumberOfItems){ | |
listItemPointer=allHTMLListItems.length; | |
} | |
} | |
} | |
if(superSexyMode=="on"||superSexyMode=="yes"){ | |
foo=document.getElementById('histlegend').innerHTML; | |
foo=foo.split('External tools: ')[1]; | |
foo=foo.split('(cur)')[0]; | |
foo=foo.split('<a ').join('<li><a '); | |
foo=foo.split('</a>').join('</a></li>'); | |
foo=foo.split('<b>·</b>').join(''); | |
foo=foo.split('white-space:nowrap;').join(''); | |
document.getElementById('p-tb').innerHTML=document.getElementById('p-tb').innerHTML+'<h3>External tools</h3><div style="display: block;" class="body"><ul>'+foo+"</ul></div>"; | |
document.getElementById('histlegend').innerHTML=""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment