本WIKI为帮助各位传承者,更好的游玩斗罗大陆:逆转时空而建立,现处于建设中
来自斗罗大陆:逆转时空
跳到导航 跳到搜索

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
/*
** BilibiliVideo
** Author:马小萌
** Bilibili:https://space.bilibili.com/123855714
**/
"use strict";
$(function() {
    $(".bvideo").each(function(i){
        var id = $(this).data("id").toString().replace(/^(av|bv)*(\w{10}|\d+)$/i,"$2");
        var cid = $(this).data("cid");
        var page = $(this).data("page");
        var title = $(this).data("title");
        var width = $(this).data("width");
        var height = $(this).data("height");
        var idname = isNaN(id)?"bvid=BV":"aid=";
        width=Math.min(width,$(this).parents()[2].clientWidth-40);
        $.getJSON(`https://api.bilibili.com/x/web-interface/view?${idname}${id}`,function(result) {
            if(result.code==0){
                if(title == "") title = result.data.title;
                if(cid==0){
	                result.data.pages.forEach(function(item) {
                        if(item.page == page){
                            cid = item.cid;
                            return;
                        }
                	});
                }
                height=height>359?height+46:height;
                $("<iframe>").css({
                    "width":width,
                    "height":height,
                    "margin":"0 20px;"
                }).attr({
                    "max-width":"100%",
                    "scrolling":"no",
                    "border":"0",
                    "frameborder":"no",
                    "framespacing":"0",
                    "allowfullscreen":"true",
                    "src":`//player.bilibili.com/player.html?aid=${result.data.aid}&bvid=${result.data.bvid}&page=${page}&cid=${cid}&high_quality=1&crossDomain=1&from=wiki&autoplay=0`
                }).appendTo(`[data-id$=${id}][data-page=${page}]`);
                $(`<ul>
<li>如果无法观看,请检查是否启用了H5播放器,或点击下方链接</li>
<li><a href="https://www.bilibili.com/video/${result.data.bvid}/?p=${page}" title="${result.data.title}">${title}</a></li>
</ul>`).appendTo(`[data-id$=${id}][data-page=${page}]`);
                console.log(title, "载入完成。(aid=",result.data.aid,",bvid=",result.data.bvid,",p=",page,",cid=",cid,")");
            }else{
                $("<span>啊咧?!视频不见了!</span>").appendTo(`[data-id$=${id}][data-page=${page}]`);
                console.log(isNaN(id)?"BV"+id:"av"+id, "载入失败。(",result.message,")");
            }
        });
    });
    console.log("%c BilibiliVideo %c https://wiki.biligame.com/wiki/?curid=2342", "color: #fff; padding: 5px 0; background: #9dbafc;", "padding: 5px 5px 5px 0; background: #e5e5ff;");
});