// Crudely replaces all PNG thumbnails for SVG files with their actual SVGs
// Warning: Downloads SVG files in addition to PNGs, so shouldn't be used
// by the bandwidth-conscious
// License: CC0
function replaceSvg() {
if (!(mw.config.get('wgAction') === 'view' && mw.config.get('wgIsArticle'))) {
return;
}
$("#bodyContent img[src$='.svg.png']").each(function() {
var src = $(this).attr("src");
// Regex will break if thumbnail URL structure changes
src = src.replace(/(\/\/.*)\/thumb(.*.svg).*.svg.png/, "$1$2");
$(this).attr("src", src);
$(this).removeAttr("srcset");
});
}
$(replaceSvg);