User:Connel MacKenzie/diff.js
Appearance
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
function addWiktDiffQuestion() {
//disambig-see-also, .disambig-see-also-2
var wiktSpans = document.getElementsByTagName('div');
var wiktDisambigSeeAlso;
if (wiktSpans) {
for (var i=0; i<wiktSpans.length; i ) {
if ( wiktSpans[i].getAttribute('class') ) {
if ( wiktSpans[i].getAttribute('class') == 'disambig-see-also' ) {wiktDisambigSeeAlso = wiktSpans[i];}
if ( wiktSpans[i].getAttribute('class') == 'disambig-see-also-2' ) {wiktDisambigSeeAlso = wiktSpans[i];}
}
}
}
if ( (wiktDisambigSeeAlso) ) {
var wiktAs = wiktDisambigSeeAlso;
for (var x=0; wiktAs.childNodes[x]; x ) {
wiktAs2 = wiktAs.childNodes[x].innerHTML;
if ( wiktAs2 ) {
if ( wiktAs2.split('"')[0] == '<a href=' ) {
var what2d = wiktAs2.split('/wiki/')[1];
if (what2d) what2d = what2d.split('"')[0];
if (what2d) {
var newa = document.createElement('a');
newa.href = '/w/index.php?title=' what2d '&diff=next&oldid=' wgCurRevisionId;
var newl = document.createTextNode('(diff)');
newa.appendChild(newl);
var newsp = document.createTextNode(' ');
wiktAs.childNodes[x].appendChild(newsp);
wiktAs.childNodes[x].appendChild(newa);
}
}
}
}
}
/* remove this cruft until a better place for the input box is suggested.
var box = document.createElement('input');
box.type = 'text';
box.width = 30
box.id = 'wiktDiff';
box.name = 'wiktDiff';
var wiktBoxButton = document.createElement('input');
wiktBoxButton.type = 'submit';
wiktBoxButton.name = 'Diff';
wiktBoxButton.value = 'diff';
wiktBoxButton.onclick = function() {
document.location = 'http://en.wiktionary.org/w/index.php?title='
document.getElementById('wiktDiff').value.replace(' ', '_')
'&diff=next&oldid=' wgCurRevisionId;
}
var captionforBox = document.createTextNode(' - compare to some other page: ');
var firsthd = document.getElementsByTagName('H1')[0].childNodes[0];
firsthd.parentNode.appendChild( captionforBox );
firsthd.parentNode.appendChild( box );
firsthd.parentNode.appendChild( wiktBoxButton );
*/
}
$( addWiktDiffQuestion );