User:Thesevenseas/pagediff.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
if (typeof (pagediff) == 'undefined') { // Guard against double inclusions
var pagediff = {
page1: "",
page2: "",
callback: function(jsonobj) {
if( jsonobj && jsonobj.query ) {
var revid1 = 0;
var revid2 = 0;
for (var page in jsonobj.query.pages) {
var p = jsonobj.query.pages[page];
if( !revid1 ) revid1 = p.revisions[0].revid;
else revid2 = p.revisions[0].revid;
}
}
document.location.href = wgScript + "?title=" + encodeURIComponent( "User:Thesevenseas/Pagediff" )+ "&oldid=" + revid1 + "&diff=" + revid2;
},
setup: function() {
pagediff.page1 = getURLParamValue( "oldpage" ).replace( "+", "_" );
pagediff.page2 = getURLParamValue( "newpage" ).replace( "+", "_" );
mw.loader.load( wgScriptPath + "/api.php?action=query&format=json&prop=revisions&rvprop=ids&titles=" + encodeURIComponent(pagediff.page1) + "|" + encodeURIComponent(pagediff.page2) + "&callback=pagediff.callback" );
}
}
}
pagediff.setup();