User:Timwi/externaldiff.js

// add link to diff pages for running external diff application function externalDiffLoadHandler { var loc = document.location; var bodyContent = document.getElementById ('bodyContent'); if ((matches = /^http:\/\/([a-z0-9.]+)\/w\/index\.php\?title=([^&]+)(?:&curid=\d+)?&(diff=[0-9a-z]+&oldid=[0-9a-z]+)$/ .exec (loc)) && bodyContent) { var obj = document.createElement ('a'); obj.href = 'wpdiff://' + matches[1] + '/' + matches[2] + '?' + matches[3]; obj.innerHTML = 'View this diff in external application'; bodyContent.insertBefore (obj, bodyContent.firstChild); } } addOnloadHook(externalDiffLoadHandler);