MediaWiki:Gadget-temp-svgFix.js

来自萌娘共享
跳转至: 导航搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
/**
 * -------------------------------------------------------------------------
 * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
 * -------------------------------------------------------------------------
 */
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/temp-svgFix/MediaWiki:Gadget-temp-svgFix.js|user=[[U:AnnAngela]]|co-authors=|longId=ec2fbee17f83ab700b67b0a8898e660d137c23f4|shortId=ec2fbee|summary=feat(Gadget-temp-svgFix): update SVG image selector to include lazy-loaded images|body=<nowiki>The selector for SVG images was updated to include images that are loaded lazily. This will ensure that all affected SVG images receive appropriate processing.</nowiki>}}'; 

/* <pre> */

"use strict";
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
$(function () {
    var e_1, _a;
    var svgs = Array.from(document.querySelectorAll('img[src$=".svg.png"], img[data-lazy-src$=".svg.png"]'));
    try {
        for (var svgs_1 = __values(svgs), svgs_1_1 = svgs_1.next(); !svgs_1_1.done; svgs_1_1 = svgs_1.next()) {
            var img = svgs_1_1.value;
            try {
                var src = img.src || img.dataset.lazySrc;
                var url = new mw.Uri(src);
                if (url.host !== "img.moegirl.org.cn") {
                    continue;
                }
                img.src = src.replace("/thumb/", "/").replace(/\.svg\/[^/]+\.svg\.png$/, ".svg");
                img.removeAttribute("srcset");
                img.removeAttribute("data-lazy-src");
                img.removeAttribute("data-lazy-srcset");
                img.removeAttribute("data-lazy-state");
                img.classList.remove("lazyload");
                img.after(img.cloneNode(true));
                img.remove();
            }
            catch (_b) { }
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (svgs_1_1 && !svgs_1_1.done && (_a = svgs_1["return"])) _a.call(svgs_1);
        }
        finally { if (e_1) throw e_1.error; }
    }
}); 

/* </pre> */