“Widget:BilibiliVideo”的版本间的差异

来自维阿百科
跳转至: 导航搜索
(导入1个版本)
第105行: 第105行:
 
     background: white;
 
     background: white;
 
     padding: 0px 0.5em;
 
     padding: 0px 0.5em;
}
 
html > body > .navpopup .bilibili-video-container > * {
 
    display: none !important;
 
}
 
html > body > .navpopup .bilibili-video-container::before {
 
    content: "请不要在注释里使用 BilibiliVideo 模板";
 
    font-style: italic;
 
 
}
 
}
 
</style><script>
 
</style><script>
 
"use strict";
 
"use strict";
window.RLQ.push(async () => {
+
window.RLQ.push(() => {
 
     const errMsg = {
 
     const errMsg = {
 
         id: '此处填写的id有误,请参考<a href="https://zh.moegirl.org.cn/Template:BilibiliVideo#firstHeading" target="_blank">模板文档</a>修正……',
 
         id: '此处填写的id有误,请参考<a href="https://zh.moegirl.org.cn/Template:BilibiliVideo#firstHeading" target="_blank">模板文档</a>修正……',
第121行: 第114行:
 
         attr: '下方填写的参数 $$$ 有误,请参考<a href="https://zh.moegirl.org.cn/Template:BilibiliVideo#firstHeading" target="_blank">模板文档</a>修正……',
 
         attr: '下方填写的参数 $$$ 有误,请参考<a href="https://zh.moegirl.org.cn/Template:BilibiliVideo#firstHeading" target="_blank">模板文档</a>修正……',
 
     };
 
     };
    await $.ready;
 
    const ifNamespaceAllow = [0, 4, 10, 12].includes(mw.config.get("wgNamespaceNumber"));
 
 
     const sanNode = $(`<${"span/"}>`);
 
     const sanNode = $(`<${"span/"}>`);
 
     const genErr = (type, msg = "") => type in errMsg ? `<${"div"} style="font-style: italic; border: 1px dashed red;">BilibiliVideo模板:${errMsg[type].replace("$$$", sanNode.text(msg).html())}<${"/div"}>` : "";
 
     const genErr = (type, msg = "") => type in errMsg ? `<${"div"} style="font-style: italic; border: 1px dashed red;">BilibiliVideo模板:${errMsg[type].replace("$$$", sanNode.text(msg).html())}<${"/div"}>` : "";
 
     const injectErrMsgBefore = ($ele, type, msg = "") => $ele.before(genErr(type, msg));
 
     const injectErrMsgBefore = ($ele, type, msg = "") => $ele.before(genErr(type, msg));
    const getErrorType = (code) => {
 
        switch (code) {
 
            case 62003: {
 
                return false;
 
            }
 
            case -403: {
 
                return "forbidden";
 
            }
 
            default: {
 
                return "failed";
 
            }
 
        }
 
    };
 
 
     try {
 
     try {
 
         const isNaN = Number.isNaN || window.isNaN;
 
         const isNaN = Number.isNaN || window.isNaN;
第186行: 第164行:
 
             }
 
             }
 
             return false;
 
             return false;
        };
 
        const submit = (ids) => {
 
            if (!ifNamespaceAllow) {
 
                return;
 
            }
 
            if (--ids.pending > 0) {
 
                return;
 
            }
 
            let changed = false;
 
            if (ids.failed.aid.size + ids.failed.bvid.size > 0 && !mw.config.get("wgCategories").includes("带有失效视频的条目")) {
 
                changed = true;
 
            }
 
            if (ids.forbidden.aid.size + ids.forbidden.bvid.size > 0 && !mw.config.get("wgCategories").includes("带有受限视频的条目")) {
 
                changed = true;
 
            }
 
            if (ids.failed.aid.size + ids.failed.bvid.size === 0 && mw.config.get("wgCategories").includes("带有失效视频的条目")) {
 
                changed = true;
 
            }
 
            if (ids.forbidden.aid.size + ids.forbidden.bvid.size === 0 && mw.config.get("wgCategories").includes("带有受限视频的条目")) {
 
                changed = true;
 
            }
 
            if (changed) {
 
                const url = new URL("https://moegirlpedia.annangela.cn/bilibiliCollector/videoCheck");
 
                url.searchParams.set("pageid", mw.config.get("wgArticleId"));
 
                $.get(`${url}`);
 
            }
 
 
         };
 
         };
 
         if (mw.config.get("skin") === "minerva") {
 
         if (mw.config.get("skin") === "minerva") {
             const ids = {
+
             $(".bilibili-video-container:not(.bilibili-video-initialized)").each((_, ele) => {
                failed: {
 
                    aid: new Set(),
 
                    bvid: new Set(),
 
                },
 
                forbidden: {
 
                    aid: new Set(),
 
                    bvid: new Set(),
 
                },
 
                pending: 0,
 
            };
 
            const targets = $(".bilibili-video-container:not(.bilibili-video-initialized)");
 
            ids.pending = targets.length;
 
            targets.each((_, ele) => {
 
 
                 const element = $(ele),
 
                 const element = $(ele),
 
                     dataset = ele.dataset;
 
                     dataset = ele.dataset;
第267行: 第206行:
 
                             element.before($("<a/>").addClass("bilibili-video-button").attr("rel", "nofollow noreferrer noopener").attr("href", `https://www.bilibili.com/video/${prefix.href}${id}?p=${page}${tIsInvalid ? "" : `&t=${t}`}`).text((title || prefix.href + id) + (![0, 1].includes(page) && !isNaN(page) ? ` (P${page})` : ""))).remove();
 
                             element.before($("<a/>").addClass("bilibili-video-button").attr("rel", "nofollow noreferrer noopener").attr("href", `https://www.bilibili.com/video/${prefix.href}${id}?p=${page}${tIsInvalid ? "" : `&t=${t}`}`).text((title || prefix.href + id) + (![0, 1].includes(page) && !isNaN(page) ? ` (P${page})` : ""))).remove();
 
                             console.info("Widget:BilibiliVideo", `${prefix.href}${id}`, code, message);
 
                             console.info("Widget:BilibiliVideo", `${prefix.href}${id}`, code, message);
                            const errorType = getErrorType(code);
 
                            if (errorType) {
 
                                ids[errorType][prefix.iframe].add(id);
 
                            }
 
 
                             return;
 
                             return;
 
                         }
 
                         }
第295行: 第230行:
 
                     error: function () {
 
                     error: function () {
 
                         element.before($("<a/>").addClass("bilibili-video-button").attr("rel", "nofollow noreferrer noopener").attr("href", `https://www.bilibili.com/video/${prefix.href}${id}?p=${page}${tIsInvalid ? "" : `&t=${t}`}`).text((title || prefix.href + id) + (![0, 1].includes(page) && !isNaN(page) ? ` (P${page})` : ""))).remove();
 
                         element.before($("<a/>").addClass("bilibili-video-button").attr("rel", "nofollow noreferrer noopener").attr("href", `https://www.bilibili.com/video/${prefix.href}${id}?p=${page}${tIsInvalid ? "" : `&t=${t}`}`).text((title || prefix.href + id) + (![0, 1].includes(page) && !isNaN(page) ? ` (P${page})` : ""))).remove();
                    },
 
                    complete: () => {
 
                        submit(ids);
 
 
                     },
 
                     },
 
                 });
 
                 });
第360行: 第292行:
 
                 };
 
                 };
 
             const run = () => {
 
             const run = () => {
                 const ids = {
+
                 $(".bilibili-video-container:not(.exec)").addClass("exec").each((_, ele) => {
                    failed: {
 
                        aid: new Set(),
 
                        bvid: new Set(),
 
                    },
 
                    forbidden: {
 
                        aid: new Set(),
 
                        bvid: new Set(),
 
                    },
 
                    pending: 0,
 
                };
 
                const targets = $(".bilibili-video-container:not(.exec)");
 
                ids.pending = targets.length;
 
                targets.addClass("exec").each((_, ele) => {
 
 
                     const dataset = ele.dataset;
 
                     const dataset = ele.dataset;
 
                     const _id = dataset.id;
 
                     const _id = dataset.id;
第473行: 第392行:
 
                                 lazyLoadObserver.observe(iframe[0]);
 
                                 lazyLoadObserver.observe(iframe[0]);
 
                                 console.info("Widget:BilibiliVideo", `${prefix.href}${id}`, code, message);
 
                                 console.info("Widget:BilibiliVideo", `${prefix.href}${id}`, code, message);
                                const errorType = getErrorType(code);
 
                                if (errorType) {
 
                                    ids[errorType][prefix.iframe].add(id);
 
                                }
 
 
                                 return;
 
                                 return;
 
                             }
 
                             }
第516行: 第431行:
 
                                 selfbox.removeAttr("style");
 
                                 selfbox.removeAttr("style");
 
                             }
 
                             }
                            submit(ids);
 
 
                         },
 
                         },
 
                     });
 
                     });

2022年7月9日 (六) 13:32的版本

名称: Bilibili视频插件
作者: 加大号的猫
修订: Boxsnake
重修订: AnnAngela
H5版再修订:
新H5版又修订:
移动版支持: XYZ指示物
第三方网站支持魔改 霓虹灯鱼
版权协定: MIT
发布日期:

2012年6月29日第一版发布;
2015年2月6日更新;
2016年11月29日更新更多细节;
2017年4月10日更新至H5版(感谢众多dalao的debug_(:зゝ∠)_);
2020年01月27日更新至新版H5播放器。
2022年7月9日魔改为白名单外网站也能用的但是只有360P可用版本。

发布地址: https://zh.moegirl.org.cn/Widget:BilibiliVideo && https://zh.moegirl.org.cn/Template:BilibiliVideo
注意事项: 如有问题,请联系作者。

本Widget不能单独使用,请使用{{BilibiliVideo}}!