Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
(() => {
    const srcRegex =
        /^((?:https?:)?\/\/upload\.wikimedia\.org\/.*)\/thumb(\/.*\/)(\d{14}%21|)(.*)\/(\d+)px-\4(.*)$/;
    $('img').each((index, elem) => {
        let img = $(elem);
        let matches = srcRegex.exec(img.attr('src'));
        if (matches && /\.svg$/i.test(matches[4]) && matches[6] === '.png') {
            let div = $('<div>').insertAfter(img);
            div.attr('class', img.attr('class'));
            div.css({
                display: 'none',
                overflow: 'clip',
                verticalAlign: img.css('vertical-align')
            });
            let obj = $('<object type="image/svg+xml">').appendTo(div);
            obj.attr('data', matches.slice(1, 5).join(''));
            let img2 = $('<img>').appendTo(div);
            img2.on('load', () => {
                div.css({display: 'inline-block'});
                div.width(img.width()).height(img.height());
                let scaleX = img.width() / img2.width();
                let scaleY = img.height() / img2.height();
                obj.css({
                    display: 'block',
                    transformOrigin: 'top left',
                    scale: `${scaleX} ${scaleY}`
                });
                obj.width(img2.width()).height(img2.height());
                img.remove();
                img2.remove();
            });
            img2.on('error', (e) => {
                console.log(img2, e);
            });
            img2.attr('src', matches.slice(1, 5).join(''));
        }
    });
})();