打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模板:插入B站视频/com.js

来自Gal中文百科
Yexiaoyu留言 | 贡献2023年12月7日 (四) 19:12的版本 (创建页面,内容为“** 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"); v…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

/*

"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}]`);

$(`

`).appendTo(`[data-id$=${id}][data-page=${page}]`);

               console.log(title, "载入完成。(aid=",result.data.aid,",bvid=",result.data.bvid,",p=",page,",cid=",cid,")");
           }else{
               $("啊咧?!视频不见了!").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;");

});