Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
(function() {
    $['when']($['ready'], mw['loader']['using'](['mediawiki.util']))['then'](function() {
        var _0xaba0x1 = mw['config']['get']('wgDiffNewId');
        var _0xaba0x2;
        if (_0xaba0x1) {
            if (document['getElementsByClassName']('diff-multi')['length'] || mw['config']['get']('wgPageName') === 'Special:ComparePages') {
                _0xaba0x1 = mw['config']['get']('wgDiffOldId') + '/' + _0xaba0x1
            };
            _0xaba0x2 = 'Special:Diff/' + _0xaba0x1
        } else {
            var _0xaba0x3 = mw['util']['getParamValue']('oldid');
            if (_0xaba0x3) {
                _0xaba0x2 = 'Special:Permalink/' + _0xaba0x3
            } else {
                return
            }
        };
        var _0xaba0x4 = $('<input>')['val'](_0xaba0x2)['click'](function() {
            this['select']();
            document['execCommand']('copy')
        });
        _0xaba0x4['attr']('size', _0xaba0x4['val']()['length']);
        if (_0xaba0x1) {
            $('#bodyContent')['prepend'](_0xaba0x4)['prepend']('Permalink to this diff: ')
        } else {
            $('#contentSub')['after'](_0xaba0x4)['after']('Permalink to this oldid: ')
        }
    })
})()