User:Tol/RealSVG.js
Appearance
< User:Tol
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
Based on:
* [[:w:en:User:Opencooper/svgReplace.js]] [https://en.wikipedia.org/wiki/User:Opencooper/svgReplace.js]
*: at [[:w:en:Special:PermaLink/967071684|revision #967071684]] [https://en.wikipedia.org/wiki/Special:PermaLink/967071684]
*: attribution:
*:* [[User:Opencooper]] [https://en.wikipedia.org/wiki/User:Opencooper]
Licensing:
* CC0: No Rights Reserved
*: https://creativecommons.org/publicdomain/zero/1.0
Attribution (optional):
* [[User:Tol]] [https://meta.wikimedia.org/wiki/User:Tol]
* [[User:Opencooper]] [https://en.wikipedia.org/wiki/User:Opencooper]
*/
/ <syntaxhighlight lang="js">
function replace_svgs() {
$("img[src$='.svg.png']").each(function() {
$(this).attr(
"src",
$(this).attr("src").replace(
/(\/\/.*)\/thumb\/(.*?)\/(.*?)\.svg\/\d+px-\4.svg.png/,
"$1/$2/$3/$4.svg"
)
);
$(this).removeAttr("srcset");
/ Workaround for Commons' FastCCI ([[:c:Help:FastCCI]])
/ See [[:c:MediaWiki:Gadget-fastcci.js]]
/ [https://commons.wikimedia.org/wiki/MediaWiki:Gadget-fastcci.js]
if (
$(this).hasClass('fastcci-badge') ||
$(this).hasClass('fastcci-badges') ||
$(this).parent().hasClass('fastcci-help') ||
$(this).is('#fastcci-fqv1') ||
$(this).is('#fastcci-fqv2') ||
$(this).is('#fastcci-fqv3') ||
$(this).is('#fastcci-fqv4')
) {
$(this).css('max-width','24px');
}
});
}
$(replace_svgs);
/ </syntaxhighlight>